Toc Unit Iv
Toc Unit Iv
For every CFL L there is an integer n, such that for every string z in L of length ≥ n, there exists z = uvwxy
such that:
• |vwx| ≤ n.
• |vx| > 0.
• For all i ≥ 0, uviwxi y ∈ L
The steps to prove that the language is not a context free by using pumping lemma are explained below −
Example
Find out whether L={xnynzn|n>=1} is context free or not
Solution
Case 1:
v and y each contain only one type of symbol.
{we are considering only v and y because v and y has power uv2xy2z}
X xx x yyyyz z zz
=uvkxykz when k=2
=xxxxxxyyyyzzzzz
=x6y4z5
(Number of x # number of y #number of z)
Therefore,The resultant string is not satisfying the condition
x6y4z5 ∉ L
If one case fails then no need to check another condition.
Case 2:
Either v or y has more than one kind of symbols
Xx xx yy y y zzzz
=uvkxykz (k=2)
=uv2xy2z
=xxxxyyxxyyyyyzzzz
=x4y2x2y5z2
This string is not following the pattern of our string x nynzn
Union : If L1 and L2 are two context free languages, their union L1 ∪ L2 will also be context free. For example,
L1 = { anbncm | m >= 0 and n >= 0 } and L2 = { a nbmcm | n >= 0 and m >= 0 }
L3 = L1 ∪ L2 = { anbncm ∪ anbmcm | n >= 0, m >= 0 } is also context free.
L1 says number of a’s should be equal to number of b’s and L2 says number of b’s should be equal to number of
c’s. Their union says either of two conditions to be true. So it is also context free language.
Note: So CFL are closed under Union.
Concatenation : If L1 and If L2 are two context free languages, their concatenation L1.L2 will also be context free.
For example,
L1 = { anbn | n >= 0 } and L2 = { c mdm | m >= 0 }
L3 = L1.L2 = { anbncmdm | m >= 0 and n >= 0} is also context free.
L1 says number of a’s should be equal to number of b’s and L2 says number of c’s
should be equal to number of d’s. Their concatenation says first number of a’s should be equal to number of b’s,
then number of c’s should be equal to number of d’s. So, we can create a PDA which will first push for a’s, pop for
b’s, push for c’s then pop for d’s. So it can be accepted by pushdown automata, hence context free.
Note: So CFL are closed under Concatenation.
Kleene Closure : If L1 is context free, its Kleene closure L1* will also be context free. For example,
L1 = { anbn | n >= 0 }
L1* = { anbn | n >= 0 }* is also context free.
Note :So CFL are closed under Kleen Closure.
Intersection and complementation : If L1 and If L2 are two context free languages, their intersection L1 ∩ L2
need not be context free. For example,
L1 = { anbncm | n >= 0 and m >= 0 } and L2 = (a mbncn | n >= 0 and m >= 0 }
L3 = L1 ∩ L2 = { anbncn | n >= 0 } need not be context free.
L1 says number of a’s should be equal to number of b’s and L2 says number of b’s should be equal to number of
c’s. Their intersection says both conditions need to be true, but push down automata can compare only two. So it
cannot be accepted by pushdown automata, hence not context free.
Similarly, complementation of context free language L1 which is ∑* – L1, need not be context free.
Note : So CFL are not closed under Intersection and Complementation.
Multi-track
Multi-tape
Multi-head
Multi-dimensional tape
The off-line Turing machine
UNDECIDABILITY:
The problems for which we can’t construct an algorithm that can answer the problem correctly in the infinite time are termed
as Undecidable Problems in the theory of computation (TOC).
A problem is undecidable if there is no Turing machine that will always halt an infinite amount of time to answer as
‘yes’ or ‘no’.
Examples
The examples of undecidable problems are explained below. Here, CFG refers to Context Free Grammar.
Whether two CFG L and M equal − Since, we cannot determine all the strings of any CFG, we can predict that two
CFG are equal or not.
Given a context-free language, there is no Turing machine (TM) that will always halt an infinite amount of time and
give an answer to whether language is ambiguous or not.
Given two context-free languages, there is no Turing machine that will always halt an infinite amount of time and give
an answer whether two context-free languages are equal or not.
Whether CFG will generate all possible strings of the input alphabet (∑*) is undecidable.