Indian Institute of Technology, Kharagpur: Date No. of Students
Indian Institute of Technology, Kharagpur: Date No. of Students
1. Answer with a short justification whether the following claims are true or false. No
credit will be given for writing only true or false. Assume the alphabet Σ = {0, 1} unless
specified otherwise. < A > means an encoding of the object A. CFL (CFG): context-free
language (grammar), PDA: push-down automaton, r.e.: recursively enumerable, REΣ :
the collection of all r.e. languages over Σ.
(a) Claim: A deterministic finite state transition system over Σ with n states (the start
state is fixed) can accept 2n different languages for different choices of the set of
final states, and these languages form a Boolean algebra.
True: The set Σ∗ is partitioned by the DFA M = (Q, Σ, δ, q0 , F ) in |Q| = n
equivalence classes (Myhill-Nerode), where every state corresponds to an equiva-
lence class - two strings x, y ∈ Σ∗ are said to be related (binary relation ≡M ) if
δ(q0 , x) = δ(q0 , y). This can be shown to be an equivalence relation. If F = Q, Σ∗
is accepted, if F = ∅, ∅ is accepted. Let A, B ⊆ Q, LA or LB are the languages
accepted when F = A or F = B respectively. If F = A ∪ B, the language accepted
is LA ∪ LB , if F = A ∩ B, the language accepted is LA ∩ LB , if F = Q \ A, the
language accepted is Σ∗ \ LA . So is the claim.
(b) Claim: There are only finite number of unambiguous CFGs for the language L =
{0n 1n : n ≥ 1}.
False: There are unambiguous CFG’s for every k = 1, 2, 3, · · ·. The production
rules of the kth CFG (k is fixed) are:
S → 01 | 0011 | · · · | 0k 1k | 0k S1k .
Taking k = 3, the rulwes are S → 01 | 0011 | 000111 | 000S111.
(c) Let C = {L ⊆ Σ∗ : L is co-finite}.
Claim: Each element of C is a CFL and intersections of any two of them is also a
CFL.
True: Each language L ∈ C is co-finite, so it is a regular language, and so it is
CFL. If L1 , L1 ∈ C, then L1 ∩ L2 is also a regular language, and so it is a CFL.
(d) L is a CFL, x ∈ L, and a proper prefix of x is also in L.
Claim: L cannot be accepted by a deterministic push-down automaton (DPDA) in
empty stack.
True: Let x = uv ∈ L, u ∈ L and v = ε. The DPDA will empty the stack while
accepting the string u and cannot make any move. But it is suppose to compute
on the remaining portion of the string. As it is a DPDA, there is no other choice.
1
(e) Claim: If L = {1p : p is a prime}, then there is no context-sensitive language L′ so
that LL′ is a regular language.
False: Take L′ = {1n : n ≥ 1}, which is regular and so is context-sensitive.
LL′ = {1n : n ≥ 3} is clearly regular.
(f) Claim: If L is a CFL and x ∈ L is of length greater than or equal to the pumping
constant, the number of strings of L is infinite.
True: Let the pumping constant be k and the string be w. By pumping theorem we
can write w = uvxyz, so that |vy| > 0, |vxy| ≤ l, and for each i ≥ 0, uv i xy i z ∈ L.
So the number of strings in the language are infinite.
(g) Claim: The collection of decidable or recursive languages over Σ is a Boolean
algebra with countably infinite number of elements.
True: Recursive languages cannot supersede countability as they are decided by
Turing machines. Both Σ∗ and ∅ are recursive (they are regular). This class is also
closed under union, intersection and completation. So is the claim.
(h) Claim: The length of encoding (using 0, 1) of a deterministic Turing machine over
{0, 1}, with the tape alphabet {0, 1, 6 b}, and the number of states n, is O(n).
False: We cannot go for binary encoding as 0 is to be used as separator. So
n
z }| {
Q = {1, 11, 111, · · · , 111 · · · 1} is of length O(n2 ).
(i) Claim: Every r.e. language over {0, 1} is not reducible to LHALT = {< M, w >:
M is a Turing machine that halts on input x}.
False: Every r.e. language is mapping-reducible to LHALT . Let L be a r.e.
language recognised by a Turing machine M . We can always modify M is such a
way that it halts only when it accepts a string, otherwise it runs forever. Let us
call this machine to be ML . Now the reduction mapping f (Turing computable)
is x 7→< ML , x >. Note that M is known and the Turing machine that computes
f modifies it.
It is clear that x ∈ L if and only if < ML , x >∈ LHALT .
[9 × 3]
2. (a) Use pumping theorem to prove that L = {0p 1q : p + q is not a perfect square} is
not a regular language.
Ans. Let L = {0p 1q : p+q is a perfect square} is regular and the pumping constant
2 2
be k. Naturally 0k ∈ L and by pumping theorem we can write 0k = xyz so that
(i) |y| > 0, (ii) |xy| ≤ k, (iii) for all i ≥ 0, xy i z ∈ L. Let y = 0l , where l ≤ k. Now
2 2 2
xy 2 z = 0k +l ∈ L. But then the next similar string is 0(k+1) = 0k +2k+1 . l 6= 02k+1
as l ≤ k. So it is impossible for L to be regular. Now, L = (Σ∗ \ L) ∩ L(0∗ 1∗ ). L
is regular implies L is regular - a contradiction.
(b) Use Myhill-Nerode theorem and other closure properties of regular languages to
show that L = {0m 1n : hcf(m, n) > 1} is not regular.
Ans. If possible L = {0p 1q : hcf(m, n) = 1} is accepted by the DFA M =
(Q, {0, 1}, δ, q0 , F ).
But we claim that 0p and 0q , where p, q are two distinct primes can not be equiv-
alent i.e. δ(q0 , 0p ) 6= δ(q0 , 0q ). Otherwise, 0p 1q ∈ L implies that 0q 1q ∈ L which is
not the case.
2
But then there are infinite number of primes, so it is not possible to have a DFA.
L = (Σ∗ \ L) ∩ L(0∗ 1∗ ). If L is regular, then so is L - contradiction. So L is not
regular.
[6 + 6]
3. (a) Design a PDA (state transition diagram) that recognises the language L = {x ∈
{0, 1}∗ : x 6= ww}. $ is the bottom marker of the stack.
Ans. Design the CFG with the start symbol $ and use standard construction of
one state PDA. The CFG G = ({$, A, B, D}, {0, 1}, P, $), where profuction rules
are
$ → AB | BA | A | B
A → DAD | 0
B → DBD | 1
D → 0|1
The corresponding PDA is M = ({q}, {0, 1}, {0, 1, $, A, B, D}, δ, q, $, ∅). The tran-
sition functions are,
i. If A → α ∈ P , then (q, α) ∈ δ(q, ε, A) e.g. δ(q, ε, A) = {(q, DAD), (q, 0)}.
ii. δ(q, 0, 0) = {(q, ε)} and δ(q, 1, 1) = {(q, ε)}.
(b) Use pumping theorem to prove that L = {x ∈ {0, 1}∗ : x = ww} is not a context-
free language.
Ans. Let L be context-free and k is the pumping constant. We consider the string
1k 0k 1k 0k ∈ L and argue that pumping is impossible. [7 + 5]
c, $ $
c, A A
c, B B
p q
3
If we give ‘better’ names to the non-terminals, we get:
S → S′
S ′ → aAD | bBD | cD
A → aAX | bBX | cX
B → aAY | bBY | cY
X → b
Y → a
D → ε
(b) Let L be a prefix closed infinite context-free language. Prove that there is an
infinite regular language L′ ⊆ L.
Ans. Let the pumping constant be k. Consider a string w ∈ L of length ≥ k. We
can divide the string as w = uvxyz so that (i) |vxy| ≤ k, (ii) |vy| > 0, and for all
i ≥ 0, uv i xy i z ∈ L.
But then the language is prefix-closed, so for all i ≥ 0, (i) uv i ∈ L, if v 6= ε, or (ii)
uxy i ∈ L, if v = ε. In the first case the regular subset is uv ∗ an in the second case
the regular subset is uxy∗.
[8 + 4]
5. (a) Prove that Ld = {xi : the Turing machine Mi does not accept xi } is not Turing
recognisable.
Ans. If Ld is Turing recognisable, there is a Turing machine Md that recognises
Ld . Let the encoding of the Turing machine be the kth string i.e. < Md >= xk
and Md is Mk in our enumeration.
?
The question is whether xk ∈ Ld . If xk ∈ Ld , then Md = Mk does not accept xk
i.e. xk 6∈ Ld . If xk 6∈ Ld , then Md = Mk does not accept xk i.e. xk ∈ Ld . So,
xk ∈ Ld if and only if xk 6∈ Ld - a contradiction. So Ld is not Turing recognisable.
(b) Prove that L∅ = {< M >: M is a Turing machine and L(M ) = ∅} mapping re-
ducible to L= = {< M1 , M2 >: M1 and M2 are equivalent Turing machines} as
well L6= = {< M1 , M2 >: M1 and M2 are not equivalent Turing machines}.
What is your conclusion from this result?
Ans. We construct a Turing machine Me so that L(Me ) = ∅. The mapping
reduction is < M >7→< M, Me >. It is clear that < M >∈ L∅ if and only if
< M, Me >∈ L= .
4
i. If y 6=< M >, reject y as such a string by definition encodes a machine whose
language is empty,
ii. for i = 1, 2, 3, · · · do the following steps
iii. enumerate x1 , x2 , · · · , xi ∈ Σ∗
iv. Simulate M (< M >= y) on each of these strings for i steps.
v. If one of the simulation on some xk comes to accept halt, accept y =< M >
as xk ∈ L(M ) 6= ∅.
If Lu ≤m L∅ , Lu ≤m L∅ . But we know that L∅ is recursively enumerable. That
makes Lu recursively enumerable - but that is impossible.
[3 + 6 + 3]
5
clause as uxz(vy)∗ ⊆ L. |vy| = p, so uxz(ap )i ∈ L for all i ≥ 0.
Let α = k!, we calim that w(aα )m ∈ L for all m ≥ 0, as α × m = p × m×α
p . Note
that α does not depend on w.
So for each word w ∈ L and |w| ≥ k, w(aα )m ∈ L, for all m ≥ 0.
We observe that each w ∈ L and |w| ≥ k is an element of ak+i (aα )∗ where
0 ≤ i < α. Consider the least element wi of L ∩ ak+i (aα )∗ . So the language
L = L1 ∪ L2 , where L1 is the finite collection of strings of length < k and
S
L2 = 0≤i<α wi (aα )∗ . So L is regular. [3 × 4]