Professional Documents
Culture Documents
L = { wc wr| w belong to (a | b) * }
Ø We can show that the language LS is not regular, with the help of pumping
Lemma. Further more language L is CLF governed by the CFG
S -> a S a
S -> b S b
S -> c
Let us construct a PDA with two states q1 and q2. The device will operate by
the following rules.
1) The machine starts with a Z on the stack and with the finite control in
state q1.
3) If the input to the device is C and the drive in state q1, then the state is
changed to q2.
ii) The input is b the top of the stack is a B, then the B is removed and
control remains in q2.
5) If the device is in q2 and top of the stack is Z, then the Z is removed from
the stack.
6) For all cases other than those described above, the device can make no
move.
Ø This device accepts an input string if on processing the last symbol of the
input, the stack becomes empty.
Ø When it reads the C then it changes to state q2. In state q2 the device
compares the remaining input with the symbols in the stack, if they are
identical then the stack is emptied and the input is accepted. In all other
cases the input is rejected.
ii) Acceptance by final state ie., input is accepted if the finite control
is in final state on processing the last input symbol.
Where q and pi 1 < i < m or states of the finite control, with input symbol
a and z at the top of the stack.
Ø Then by the function δ moves to the state pi for any i 1 < i < m and replaces z
with the string i.
Now let us design a formal PDA that accepts the language {wcwR| w in (a+b)*}
Ø The ID contains the state in which the PDA is in at that moment q, the
string of unexpanded input symbol w and the string being held in the
stack γ.
Ø Thus we define the IP to be a triple (q, w, γ). If m = (Q, Σ,Γ,δ _T0 ,Z0, F)
is a PDA then we say
(q, aw ,z , α) |-- (p, w, βα) if d(q, a, z)contains (p, β) i.e. the ID (p,w, βα) can be
reached from the ID (q, aw, Zα) in a single move of PDA.
Ø We use |--* for the kleen closure of |-- (ie.) for every ID I I |-- I and for Ids
I,J,K I |-- J and J |-- K implies I |-- K and I |--* J means ID J can be
reached from ID I by zero or more number of moves of the PDA.
DETERMINISTIC PDAs
A PDA is said to be deterministic if at the most one or move is possible for and
ID. Formally we say that a PDA is deterministic if
i.e. We say a PDA is deterministic if it does not have a choice of two different
moves for the same ID.
Ø Here the first condition ensures that there is no choice between a move
independent on the input tape and a move involving an input symbol a.
The second condition prevents a choice of move for any (q, a, Z).
Ø We know that for a FSA the deterministic and noon deterministic versions
were equivalent.
Accepted languages:
We have seen that a PDA may accept a string by ending up in one of the
final states or by ending up with an empty stack. So correspondingly for
Ø We first show that the languages accepted by final state are exactly the
languages accepted by PDA's by empty stack.
Ø We then show that the language accepted by empty stack is exactly the
context - free languages.
Theorem If L is L (M2) for some PDA M2 then L is N (M1) for some PDA, M1.
Proof
we would like M1 to simulate M2 enters a final state.
We use state q of M1 to erase the stack and we use a bottom of stack marker
Xa for M1 does not accidentally accept if M2 empties its stack without entering
a final state.
1) δ’(q0’, ∈,X0)={(q0,Z0,X0)}
2) δ '(q,a,z ) includes the elements of δ ( q,a,z ) for all q in Q ,
a in ∑ or a= ∈ ,and Z in Γ
3) For all q in F, and in ΓU{Xn}, δ ( q, ∈,z ), contains (q∈,∈ ).
4) For all Z in ΓU{Xn} contains (q∈,∈ ).
Ø Rule (1) causes M1 to enter the initial ID of M2 except that M1 will have its
own bottom of the stack marker Xo , which is below the symbols of M2's
stack.
Ø Rule (2) allows M1 to simulate M2. Should M2 ever enter a final state, rules
(3) and (4) allow M1 the choice of entering stae qo and crasing its tack,
thereby accepting the input, or continuing to simulate M2.
Ø One should note that M2 may possibly erase its entire stack for some input x
not in L(M2).
Ø This is the reason that M1 has its own special bottom-of-stack marker.
Theorem
If L is N (M1) for some PDA M1, then L is L (M2) for some PDA M2.
Proof Our plan now is to have M2 simulate M1 and detect when M1 empties its
stack, M2 enters a final state when and only when this occurs.
Let M1=(Q,∑,Γ, δ,θ0,Ζ0, φ)
1) δ’(q’o,∈,Xo) = {{qo,ZoXo)}
2) For all q in Q, a in ∑∪{∈}, and Z in Γ.
δ’(q,a,Z) = δ{q,a,Z)
3) For all q in Q, δ’ (q,∈, Xo) contains (qf,∈),
Ø Except that M2 will have its own bottom of stack marker X0, which is
below the symbols of M2's stack.
Theorem:
If L is a context-free language, then there exists a PDA M such that L =
N(M)
Proof :
we assume that is not in L(G). The reader may modify the construction
for the case where ∈ is in L (G).
Let M = ({q},T,V,δ,q,S,φ),
Where
δ {q,a,A} contains (q,γ) whenever A→ aγ is in P.
Ø M stores the suffix α of the left sentential form on its stack after processing
the prefix x. Formally we show that S xα ⇒ by a leftmost derivation if and only
if (q,x,S)
since x =∈ and α=S, For the induction, suppose i ≥ 1, and let x = ya.
Ø If we remove a from the end of the input string in the first j ID's of the
sequence we discover that (q,y,S)
(q, ∈,,β) ,since α can have no effect on the moves of M until it is actually
consumed from the input. By the inductive hypothesis S⇒yβ. The move
(q,α,β)|-(q,∈α) implies that β = Ay for some A in V, A→ aη an is a production of
G and α=ηy.
Hence
S⇒yβ⇒ yaηγ =xα.
1 i− →yAγ ⇒ yaηγ,
(q,a,Aγ)-(q,∈,α),
and the “only if” portion of (5.1) follows.
Ø To conclude the proof ,we have only to note that (5.1) with α = ∈says S x ⇒ if
and only if (q,x,S)
Theorem:
If L is N (M) for some PDA M, then L is a context - free language.
Proof:
Let M be the PDA (Q,∑,T,δ,qo,Zo,φ). Let G=(V,∑,P,S) be a context-free
grammar where V is the set of objects of the form (q,A,p} q and p in Q, and A in
Γ, plus the new symbol S. P is the set of productions.
Ø To understand the proof it helps to know that the variables and productions of
G have been defined in such a way that a leftmost derivation in G of a
sentence x is a simulation of the PDA M when fed the input x.
Ø Put another way, the intention is that [q.A,p] derive x if and only f x causes M
to erase an A from its stack by some sequence of moves beginning in state q
and ending in state p.
Ø The string y cn be written y=y1,y2 …..y3 where y1 has the effect of popping
Bj from the stack, possibly after a long equence of moves.
Ø That is, let y1 be the prefix of y at the end of which the stack first becomes as
short s n - 1 symbols.
Ø Let y2 be the symbols of y following y1 such that at the end of y2 the stack
first becomes as short as n-2 symbols, and so on.
Ø The arrangement is shown,Note that B1 need not be the nth stack symbol
from the bottom during the entire time y1 is being read by M since B3 may be
changed if it is at the top of stack and is replaced by one or more symbols.
Ø However, none of B2 B2 …B3 are ever at the top while y3 is being read and
so cannot be changed or influence the computation.
Where q = p. Then we may write x = ax1x2 ….x3 where for with each derivation
taking fewer than j steps.
Ø The proof concludes with the observation that (5.3) with q = qo and A=Zo
says
This observation, together with rule (1) of the construction of G, says that
For some state p.
(i.e) the substring can be repeated as many as times as possible such that the
resulting string still lies in the regular languages.
Ø The pumping Lemmar for a CFL states that every long string of a CFL
contains of two short sub-string that can be repeated the same number of time
and still the resulting string lies in the CFL.
Proof:
Let G be a CFG in CNF.
First we show that if the parse tree for a word generated by a CNF grammar
has no path of length greater than I, then the word is of length no greater than
2i –1 We use induction oni to prove this.
The case for i = 1 is trivial. We know that every production in a CNF is of the
form
A -> a or A -> BC
(i.e) for I=1 the length of the word generated is at the most |. So it is true for I=1.
Assume that this is true for all trees with no path greater than I-1 can generate
no word with length greater than 2i-2.
If there are no paths of length greater than I-1 then by the assumption the
words generated by the trees T1 and T2 are no longer than 2i-1 (2i-2 * 2).
Hence a word generated by a parse tree with no path greater than ithen the
word is no longer than 2i-1.
Let the grammar have K non-terminal symbols and let n = 2k. If ZεΤ∗ is in L(G)
and |Z| less than or equal to n, then since|Z| >2k, any parse tree for Z must
contain at least one path of length K+ 1. Such a path would have at least K+2
nodes that are labeled by non-terminals.
But the grammar now only K non-terminals, so there should be at least one
terminal is repeated twice. Let P be a path that is as long or longer than any
other path in the tree. Then there must be two nodes n1 and n2 along P such
that
i) The nodes n1 & n2 both have same label, say A.
ii) The node n1 is closer to the root than n2
iii) The portion of the path from n1 to the leaf is of length at most K+1.
Let Z1 be the yield of the sub tree T1 and if T2 is the sub tree with root as node
n2 and z2 be the yield of this sub tree.
Now we can write Z1as Z3 Z2 Z4. We can see that Z3 and Z4 cannot be both ε,
since the root of sub tree T1 is A and the first production should have been of
the form A -> BC
And the sub tree T2 should have been derived entirely from B or C.
|z3z2z4| < 2K = n.
A⇒z3Az4 z3z3Az4z4 Z3 Z3 Z3 A Z4 Z4 Z4 ….
Z = uZ3Z2Z4y and
if
Z2 = w,
Z3 = v and
Z4 = x then
We have
uvwxy ε L(G)
uviwxiy ε L(G)
When
|uvwxy| > n
|vwx| < n
|vx| > 1
PART A
1. Define PDA.
2. Write the Components of PDA.
3. Write the formal representation of PDA
4. Give the diagrammatic representation of PDA
5. What are the three ways to recognize PDA?
6. Give informal representation of PDA for the language L= {0n1n| n>=0}
7. Give the mathematical model of PDA for the language L= {0n1m|
n>=0,m>=0,m!=n}
8. Write instantaneous representation of PDA.
9. What is relation between PDA’s and CFL?
10. What is relation between NPDA and DPDA
11. Write the closure properties of CFL.
12. Define Pumping lemma for regular language.
13. Show the language L={anbncn:n>=0} is not context free.
14. Construct a PDA that accept the language generated by the grammar
SàaSbb|aab.
PART-B