You are on page 1of 2

THEORY OF COMPUTATION CS41001

Tutorial 1: Decidability
August 3, 2015
Submission Guidelines Problems 1, 2 and 3 have to be submitted in class today. Problem 4 has
to be submitted in the next tutorial class. Submissions should be done in plain paper clearly mentioning
your name and roll number.
1. Given two sequences u = (u1 , u2 , , um ) and v = (v1 , v2 , , vm ) of strings ui , vi ( is the
alphabet), the problem is to find whether there is a finite sequence (i1 , , ip ), with ij 1, m for
j = 1, , p so that, ui1 ui2 uip = vi1 vi2 vip (any number of repetitions of a string is allowed).
For example, an instance of the problem can be represented as




u1
um
, ,
v1
vm
For example, consider the following instance

 
 
 
 
 

abab
aaabbb
aab
ba
ab
aa
,
,
,
,
,
ababaaa
bb
baab
baa
ba
a
The solution is 1234556.


abab
ababaaa

aaabbb aab
bb
baab

ba ab ab aa
baa ba ba a

This problem is undecidable if the alphabet consists in at least two letters.


(a) Prove that this problem is decidable if consists in only one letter.
Solution If the alphabet is unary (let = {1}), the pairs only differ in the number of 1s that
each pair has on the top and bottom. This specific case is solved by the following algorithm:
M = Given a two sequences u = (u1 , u2 , , um ) and v = (v1 , v2 , , vm )
If i |ui | = |vi |, there is a trivial match, so accept.
If i |ui | > |vi | or |ui | < |vi | there is no possibility of a match, so reject.
If i, j |ui | > |vi | and |uj | < |vj | accept because let |ui | |vi | = a and |vj | > |uj | = b. Now


ui ui (repeated b times) uj uj (repeated a times)
vi vi (repeated b times) vj vj (repeated a times)
makes a match.
(b) Prove that this problem is decidable if in each pair, the length of the top string is the same
as the bottom string.
Solution M = Given a two sequences u = (u1 , u2 , , um ) and v = (v1 , v2 , , vm )
If i ui = vi , accept.
Else, reject.
2. Prove that EQDF A is decidable by testing the two DFAs on a finite number of strings. Calculate
a number that works.
Solution Let M1 and M2 be two given DFAs and let n1 and n2 be their respective numbers of
states. We claim that L(M 1) = L(M 2) if and only if for all strings w with |w| n1 n2 we have
w L(M1 ) if and only if w L(M2 ).
1

In order to prove this claim we assume t be the shortest string on which the two languages differ
such that |t| = l > n1 n2 . Consider the sequence of states q0 , , ql and r0 , , rl that M1 and M2
enters respectively on input t. As M1 has n1 states and M2 has n2 states, only n1 n2 distinct pairs
hq, ri exist where q is a state in M1 and r is a state in M2 . By the pigeon hole principle, two pairs
of states hqi , ri i and hqj , rj i must be identical because l > n1 n2 . If we remove the portion of t from
i to j 1, we obtain a shorter string on which M1 and M2 differs even though t was supposed to
be the shortest. This is a contradiction and thus our assumption |t| > n1 n2 is false.
3. Let J = {w| either w = 0x for some x AT M , or w = 1y for some y AT M }. Show that neither
J nor J is Turing-recognizable.
Solution We can reduce AT M to J. To determine if w AT M , prepend a 1 to w and check if
1w J. AT M is not Turing recognizable; therefore, J is not Turing recognizable either. Likewise,
we can reduce AT M to J by prepending a 0 to the input string which shows that J is not Turing
recognizable either.
4. Let C = {hG, xi|G is a CFG, x is a substring of some y L(G)}. Show that C is decidable.
Solution Consider the following Turing machine
M = On input hG, xi, where G is a CFG
(a) Let R be the following RE R = x
(b) Create the CFG H such that L(H) = L(G) L(R)
(c) Submit hGi to the decider for ECF G
(d) If it accepts, then reject
(e) Else, accept.
M is clearly a decider since it halts. Also, M accepts hG, xi iff G generates some string in x
i.e., some string with x as a substring.

You might also like