0% found this document useful (0 votes)
47 views6 pages

Indian Institute of Technology, Kharagpur: Date No. of Students

Uploaded by

Shivam Shukla
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)
47 views6 pages

Indian Institute of Technology, Kharagpur: Date No. of Students

Uploaded by

Shivam Shukla
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/ 6

INDIAN INSTITUTE OF TECHNOLOGY, KHARAGPUR

Date . . . . . . . . . . . . FN / AN Time: 2/3 Hrs. Full Marks . . . . . . . . . No. of Students . . . . . . . . .


Autumn / Spring Semester, 20 . . . . . . . . . Deptt. . . . . . . . . . . . . . . . Sub No. . . . . . . . . . . . .
. . . . . . Yr. B. Tech.(Hons.) / B. Arch. / M. Sc. Sub. Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Instruction : Answer Q1 and any Four(4) from the Remaining Questions.

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

4. (a) Consider the push-down automaton a, $ A$ b, A ε


P = ({p, q}, {a, b, c}, {$, A, B}, δ, p, $, φ) b, $ B$ a, B ε
a, A AA ε, $ ε
and formally construct an equivalent
a, B AB
context-free grammar. The accep-
b, A BA
tance is by empty-stack. Clearly ex- b, B BB
plain the non-terminals and the pro-
duction rules.
Ans. The meaningful non-terminals and productions of the grammar are N =
{S, (p$q), (pAq), (pBq), (q$q), (qAq), (qBq)} and
S → (p$q)
(p$q) → a(pAq)(q$q) | b(pBq)(q$q) | c(q$q)
(pAq) → a(pAq)(qAq) | b(pBq)(qAq) | c(qAq)
(pBq) → a(pAq)(qBq) | b(pBq)(qBq) | c(qBq)
(qAq) → b
(qBq) → a
(q$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= .

The answer to the remaining portion is not known to me!!


(c) Prove that the universal language Lu = {< M, x >: the Turing machine M accepts x}
is not mapping reducible to L∅ .
Ans. We know that L∅ is recursively enumerable. Following Turing machine
recognises this language.
M∅ :
Input: y

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]

6. Give proper justification for the following statements.

(a) Context-free languages are closed under inverse-homomorphism.


Ans. Let h : Σ∗1 → Γ∗2 be a homomorphism and L be a CFL over Σ2 . The claim
is that h−1 (L) ⊆ Σ∗ is a CFL.
Let the PDA M2 = (Q2 , Σ2 , Γ2 , δ2 , q20 , $, F2 ) recognises L2 . The PDA M1 =
(Q1 , Σ1 , Γ1 , δ1 , q10 , $, F1 ) first translates the input from Σ1 to its homomorphic
image and then runs M2 on it. So the whole input over Σ∗1 is translated to its
image over Σ∗2 and M2 is run on it. If M2 accepts, then so is M1 .
The state set takes care of the translation:

• Q1 = Q2 ×{x ∈ Σ∗2 : x is a suffix of h(a) for all a ∈ Σ1 }. The second component


of the state keeps the translation.
• q10 = (q20 , ε).
• Σ 1 = Σ 2 , Γ1 = Γ2 .
• F1 = F2 × {ε}.
The translation takes place as follows: δ1 ((p, ε), a, X) = {(p, h(a)), X)}.
(b) If L1 and L2 are recognised by deterministic Turing machines (DTMs) M1 and
M2 , then there is a DTM that recognises L1 L2 .
Ans. The DTM for L1 L2 works as follows:
M:
Input: x
i. Split the input x in two parts x = x1 x2 in all possible ways. If the length of x
is n, there are n + 1 split.
ii. for i = 1, 2, 3, 4, · · · do the following steps.
iii. Simulate M1 on the first part, x1 , and simulate M2 on the second part x2 for
i steps.
iv. If both the machines accept some split within some i steps, accept x.
(c) Any context-free language over a one-letter alphabet is a regular language.
Ans. If the language L is finite, there is nothing to prove.
Consier an infinite language L and let the pumping constant be k. So each w of
length ≥ k in the language can be written as w = uvxyz so that |vxy| ≤ k, |vy| > 0
and for all i ≥ 0, uv i xy i z ∈ L. As there is only one alphabet, we write the last

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]

Sig.of the Paper-Setter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

You might also like