CS701 PREVIOUS SOLVED MID TERM PAPER
Question CS701 Previous Mid Exam
1. Consider following instance of PCP. Is it possible to find a match?
If yes then give the domino arrangements. If NO then prove. (5)
2. Show that all positive numbers has one-to-one correspondence
to real numbers. (5)
3. Show that ATM is not mapping reducible to ETM. In other words
show that no computable function reduces ATM to ETM. (10)
(Hint: Use a proof by contradiction and facts you already know about ATM and ETM)
(Hint: Use a proof by contradiction and facts you already know about ATM and ETM)
4. In silly post corresponding problem (SPCP), in each pair the
top string has the same length as the bottom string. Show that SPCPV is
decidable. (10)
Solved
Question CS701 Previous Mid Exam
Question: Let LALL = {|M is a
TM with input alphabet Σ and L (M)=Σ*} prove that LALL is not Turing
recognizable.
0
Question 01: Show that the Post
Correspondence Problem (PCP) is decidable over unary alphabet.
Answer:
The Post Correspondence Problem (PCP) is decidable over unary alphabet. We can describe a Turning Machine M that decides unary PCP.
Given unary PCP instance
The Post Correspondence Problem (PCP) is decidable over unary alphabet. We can describe a Turning Machine M that decides unary PCP.
Given unary PCP instance
Let us design a TM M as given below:
M = “On Input ”
1. Check if for some i. if so, accept.
2. Check if there exist such that and. If so, accept otherwise reject.
Question 02: Prove that every t (n)-time k-tape TM has on equivalent single tape TM.
M = “On Input ”
1. Check if for some i. if so, accept.
2. Check if there exist such that and. If so, accept otherwise reject.
Question 02: Prove that every t (n)-time k-tape TM has on equivalent single tape TM.
Answer:
Given a k-tape TM M, we can make 1-tape TM N. N works as follows:
1. On input x, convert input x to #q0#x#, …. #(the start configuration of M). This configuration says that x is on the first tape. The rest of the tape is empty and the machine is in q0.
2. In each pass over the tape, change the current configuration to the next one.
3. If an accepting configuration is reached, accept.
4. If a rejecting configuration is reached, Reject.
Given a k-tape TM M, we can make 1-tape TM N. N works as follows:
1. On input x, convert input x to #q0#x#, …. #(the start configuration of M). This configuration says that x is on the first tape. The rest of the tape is empty and the machine is in q0.
2. In each pass over the tape, change the current configuration to the next one.
3. If an accepting configuration is reached, accept.
4. If a rejecting configuration is reached, Reject.
Now we have to
estimate, how much time does N require?
On any input x of length n, we make the following claims:
1. M uses at most t(n) cells of its k-tape.
2. Each configuration has length at most k t(n) = O(t(n)).
3. Each pass of N requires at most O(t(n)) steps.
4. N makes at most t (n) passes on its tape.
On any input x of length n, we make the following claims:
1. M uses at most t(n) cells of its k-tape.
2. Each configuration has length at most k t(n) = O(t(n)).
3. Each pass of N requires at most O(t(n)) steps.
4. N makes at most t (n) passes on its tape.
This shows that N run
in time. Here, we use the fact.
Thus, the machine convert x to the initial configuration. This takes time O(n). So total time is given below:
Thus, the machine convert x to the initial configuration. This takes time O(n). So total time is given below:
Question 03: Show that ATM is
not mapping reducible to ETM.
Answer:
Recall that ATM is un decidable, but it is recognizable so its complement is not recognizable. Note that, the complement of is recognizable, and so since we know is un decidable, It is also not recognizable.
Recall that ATM is un decidable, but it is recognizable so its complement is not recognizable. Note that, the complement of is recognizable, and so since we know is un decidable, It is also not recognizable.
Proof: We give a proof
by contradiction.
Assume, it is false that ATM is not mapping reducible to , so .
Consider since ATM is mapping reducible to , we immediately get is mapping reducible to .
Since, is recognizable, is also recognizable, but this is false, Hence a contradiction.
Assume, it is false that ATM is not mapping reducible to , so .
Consider since ATM is mapping reducible to , we immediately get is mapping reducible to .
Since, is recognizable, is also recognizable, but this is false, Hence a contradiction.
Question 04: Which of the
following pair of numbers are relatively prime? Show the calculations that lead
to your conclusions. A) 1274 & 10505 B) 7289 & 8029
Answer:
A) For checking the given number 1274 & 10505 that they are relatively prime or not we use Euclidean algorithm to find Greatest Common Divisor (GCD).
Answer:
A) For checking the given number 1274 & 10505 that they are relatively prime or not we use Euclidean algorithm to find Greatest Common Divisor (GCD).
The greatest common
divisor of 105050 and 1274 is 1. There for they are relatively prime.
B) For checking the given number 7289 & 8029 that they are relatively prime or not we use Euclidean algorithm to find Greatest Common Divisor (GCD).
B) For checking the given number 7289 & 8029 that they are relatively prime or not we use Euclidean algorithm to find Greatest Common Divisor (GCD).
The greatest common
divisor of 7289 & 8029 is 37. There for they are not relatively prime.
Question 05: G is a digraph and
show that PATH is in Class P. OR Design a polynomial time algorithm that takes
as input a graph G and two vertices s and t and decides if there is a path from
s to t.
Answer:
We have to give a polynomial time algorithm for this problem. That is “Start BFS or DFS from s and if t appears then there is a path from s to t”.
Algorithm:
I. On input <G,s,t> where G is a digraph,
II. Mark s.
III. Repeat till no additional nodes are marked:
IV. Scan the edges of G, if an edge (a,b) is found going from a, marked node a to an unmarked node b, mark b.
V. If t is marked, accept, otherwise reject.
Answer:
We have to give a polynomial time algorithm for this problem. That is “Start BFS or DFS from s and if t appears then there is a path from s to t”.
Algorithm:
I. On input <G,s,t> where G is a digraph,
II. Mark s.
III. Repeat till no additional nodes are marked:
IV. Scan the edges of G, if an edge (a,b) is found going from a, marked node a to an unmarked node b, mark b.
V. If t is marked, accept, otherwise reject.
Now we have to compute
the size of input. We know that input size is at least m, where m is the number
of nodes in G. Thus we have to show that algorithm runs in the time polynomial
in m.
The repeat loop can at most run for m time. Each time all the
edges are scanned. Since the number of edges is almost m2, thus step 2 takes at
most m2 time. So the total time is at most m3. Hence, we have shown that PATH
is in p.
Question 06: A Turning Machine with stay put instead of left is similar to an ordinary turning machine, but the transition function has the form: . At each point the machine can move its head right or left it stay in the same position.
Question 06: A Turning Machine with stay put instead of left is similar to an ordinary turning machine, but the transition function has the form: . At each point the machine can move its head right or left it stay in the same position.
Show that this turning
machine variant in not equivalent to the usual version. What class of language
does this machine recognize?
Answer:
Remembering what it
has written on the tap cells to the left of the current head position is
unnecessary, because the TM is unable to return to these cells and read them.
Using NFA in the
actual construction is convenient because it allows E moves which are useful
for simulating the “Stay Put” TM Transition.
The transition
function for the NFA is constructed according.
• First, we set, where q0 is the start state of the TM variant.
• Next, we set for any i.
• If where w=R or S, we set .
• If where w=R or S, we set.
• First, we set, where q0 is the start state of the TM variant.
• Next, we set for any i.
• If where w=R or S, we set .
• If where w=R or S, we set.
Question 07: show that the
collection of Turning-recognizable language is closed under operation of (i)
Union (ii) Concatenation.
Answer:
I. For any two turning
recognizable languages L1 and L2, let M1 and M2 be the TMs that recognizes the
union of L1 and L2:
“On input w
Rum M1 and M2 alternatively on w step by step. If either accept, accept. If both halt and reject, then reject”
Rum M1 and M2 alternatively on w step by step. If either accept, accept. If both halt and reject, then reject”
If any of M1 and M2
accepts w, M1 will accepts w since the accepting TM will come to its accepting
state after a finite number of steps. Note that if both M1 and M2 reject and
either of them does so by looping, then TM will loop.
II. Form any two
Turning-recognizable languages L1 and L2, let M1 and M2 are the TMs that
recognize them. We construct a NTM M’ that recognizes the concatenation of L1
and L2;
“On Input w;
1. None deterministically cut w into two parts w = w1w2.
2. Run M1 on w1. If it halts and reject, reject. If it accepts, go to stage 3.
3. Run M2 on w2. If it accepts, accept. If it halts and reject, reject.”
“On Input w;
1. None deterministically cut w into two parts w = w1w2.
2. Run M1 on w1. If it halts and reject, reject. If it accepts, go to stage 3.
3. Run M2 on w2. If it accepts, accept. If it halts and reject, reject.”
If there is a way to cut w into two substrings such that M1
accepts the first part and M2 accepts the second part, w belongs to the
concatenation of L1 and L2 and M1 will accept w after a finite number of steps.
Question 08: Let X be the set {1, 2, 3, 4, 5 } and Y be the set {6, 7, 8, 9, 10}. We describe the functions f: X – Y and g: X Y in the following tables.
Question 08: Let X be the set {1, 2, 3, 4, 5 } and Y be the set {6, 7, 8, 9, 10}. We describe the functions f: X – Y and g: X Y in the following tables.
N F (n)
1 6
2 7
3 6
4 7
5 6
N G(n)
1 10
2 9
3 8
4 7
5 6
1 6
2 7
3 6
4 7
5 6
N G(n)
1 10
2 9
3 8
4 7
5 6
a. Is f one-to-one? b.
Is f onto? c. Is f a correspondence?
d. Is g one-to-one? e. Is g onto? f. Is g a correspondence?
d. Is g one-to-one? e. Is g onto? f. Is g a correspondence?
A) f is not one-to-one
because f(1)=f(3) on the other hand g is one-to-one.
B) f is not onto because there does not exist x belongs to X such that f(x)=10. But g is onto.
C) g is a correspondence because g is one-to-one and onto. f is not correspondence because f is not one-to-one and onto.
B) f is not onto because there does not exist x belongs to X such that f(x)=10. But g is onto.
C) g is a correspondence because g is one-to-one and onto. f is not correspondence because f is not one-to-one and onto.
Question 09: Show that MPCP is
un decidable.
Answer:
Assume that MPCP is decidable. Let us say we have a decider R for MPCP. Consider the following decider S
Assume that MPCP is decidable. Let us say we have a decider R for MPCP. Consider the following decider S
1. On input < M, w
>
2. Construct p as described in the seven parts.
3. Run R on P‟.
4. If R accepts, accept.
5. If R rejects, reject.
2. Construct p as described in the seven parts.
3. Run R on P‟.
4. If R accepts, accept.
5. If R rejects, reject.
Then S is a decider
for ATM, which is a contradiction to the fact that ATM is un decidable.
Question 10: If A ≤m B and B is
decidable, then A is decidable.
Answer:
Proof: Since B is decidable hence there is a decider M that decides B.
Now, consider the following decider N:
Proof: Since B is decidable hence there is a decider M that decides B.
Now, consider the following decider N:
1. On input x
2. Compute y = f(x)
3. Run M on y
4. If M accepts, accept.
5. If M rejects, reject.
2. Compute y = f(x)
3. Run M on y
4. If M accepts, accept.
5. If M rejects, reject.
Since f is a
computable function and M is a decider therefore N is a decider. Furthermore, x
is accepted by N if and only if y is accepted by M. However, y is accepted by M
if and only if .
Since f is a reduction therefore, if and only if . Which implies that N accepts x if and only if . This shows that N is a decider for A.
Since f is a reduction therefore, if and only if . Which implies that N accepts x if and only if . This shows that N is a decider for A.
Question 11: If A ≤m B and B is
Turning Recognizable, then A is Turning Recognizable.
Answer:
Let A ≤m B and let f be the reducibility from A to B, Furthermore, since B is turning recognizable, there is a TM M such that L(M)=B
Answer:
Let A ≤m B and let f be the reducibility from A to B, Furthermore, since B is turning recognizable, there is a TM M such that L(M)=B
Consider N:
“On input x
1. Computer y=f(x)
2. Run M on y
3. if M accepts, accept.”
Then it is easy to see that L (N) = A.
“On input x
1. Computer y=f(x)
2. Run M on y
3. if M accepts, accept.”
Then it is easy to see that L (N) = A.
Question 12: let .show that T
is countable.
Answer:
We need to demonstrate a one-to-one . Let. Function f is one-to-one because. Therefore, T is countable.
We need to demonstrate a one-to-one . Let. Function f is one-to-one because. Therefore, T is countable.
Question 13: Let A be
a regular expression. Show that A is decidable.
Answer:
1. Proof is actually one line.
2. If we have a decider M that accepts A.
3. We can switch the accept and reject states to make another decider M‟.
4. M‟ accepts. A
1. Proof is actually one line.
2. If we have a decider M that accepts A.
3. We can switch the accept and reject states to make another decider M‟.
4. M‟ accepts. A
Lets recall that a
language A is Turing recognizable if there is a TM M such that L(M) = A.
Question 14:
Answer:
For checking the given number “234 and 399” that they are relatively prime or not we use Euclidean algorithm to find Greatest Common Divisor (GCD).
For checking the given number “234 and 399” that they are relatively prime or not we use Euclidean algorithm to find Greatest Common Divisor (GCD).
The greatest common divisor
of “234 and 399” is 3. There for they are not relatively prime
Question 15: Show that some
true statement in TH(N, +, X) are not provable
Answer:
Consider the following algorithm:
1. On input Ф
2. Enumerate all possible proofs
3. Check if is a proof of Ф. If it is accept.
4. Check if is a proof of ¬Ð¤. if it is reject.
Consider the following algorithm:
1. On input Ф
2. Enumerate all possible proofs
3. Check if is a proof of Ф. If it is accept.
4. Check if is a proof of ¬Ð¤. if it is reject.
If all true statements are provable then since each statement is
either true or false hence Ф or ≠ Ф is provable. Thus the above algorithm will
be a decider for TH(N,+,×) . This is a contradiction as we have already proved
that TH(N,+,×) is not decidable.
Question 17: MINTM is not Turing-Recognizable.
Question 17: MINTM is not Turing-Recognizable.
Answer:
Two facts about MINTM.
• 1 MINTM is infinite.
• 2 MINTM contains TM’s whose length is arbitrarily large.
If MINTM is Turing Recognizable then there is a TM E that enumerates MINTM. We will use E and the recursion theorem to construct another TM C.
• 1 MINTM is infinite.
• 2 MINTM contains TM’s whose length is arbitrarily large.
If MINTM is Turing Recognizable then there is a TM E that enumerates MINTM. We will use E and the recursion theorem to construct another TM C.
On input w
• 2 Obtain own description <C>.
• 3 Run E until a machine D appears with a longer description than that of C.
• 4 Simulate D on input w.
• 2 Obtain own description <C>.
• 3 Run E until a machine D appears with a longer description than that of C.
• 4 Simulate D on input w.
All we have to note
that eventually D will appear as MINTM contains TM with arbitrarily large
descriptions. L(C) = L(D).
However, C has a smaller description than D. So D cannot be in MINTM.
However, C has a smaller description than D. So D cannot be in MINTM.
Question 18: A={<R>|R is
a regular expression describing a language containing at least one string w
that has 111 as substring(i.e.=x111y for some x,y } show A is decidable.
Answer:
The following TM X decide A.
The following TM X decide A.
X = “On input where R
is regular Expression:
1. Construct DFA E that accepts .
2. Construct DFA B such that.
3. Run TM T on input where T decides EDFA.
4. If T accepts, reject. If T rejects, accept.”
1. Construct DFA E that accepts .
2. Construct DFA B such that.
3. Run TM T on input where T decides EDFA.
4. If T accepts, reject. If T rejects, accept.”
Question 19: Consider following
instance of PCP. Is it possible to find a match? If yes then give the dominos
arrangements. If NO then prove. 1/0. 101/1. 1/001 (5).
Answer: We can give
the number to instances as:
We have choice for
start matching that is pair B where 1 is at start from top and bottom so pair B
is,
Form pair B we can see
that 1 is match in top and bottom string but 01 is left in the upper so we need
a pair whose bottom string starts with 0. There are twp pairs A and C.
OR We cannot use C because there will be a mismatch so use A.
After using B,A from upper 10 and bottom 10 is matched but 11 is left from upper so we need a pair whose bottom string starts with 1. That is B.
Upper = 101 , Bottom = 101
OR We cannot use C because there will be a mismatch so use A.
After using B,A from upper 10 and bottom 10 is matched but 11 is left from upper so we need a pair whose bottom string starts with 1. That is B.
Upper = 101 , Bottom = 101
After using B,A,B from
upper 101 and bottom 101 is matched but 1101 is left from upper so we need a
pair whose bottom string starts with 1. That is B.
Upper = 1011 , Bottom = 1011
Upper = 1011 , Bottom = 1011
After using B,A,B,B
from upper 1011 and bottom 1011 is matched but 101101 is left from upper so we
need a pair whose bottom string starts with 1. That is B.
Upper = 10111 , Bottom = 10111
After using B,A,B,B,B from upper 10111 and bottom 10111 is matched but 01101101 is left from upper so we need a pair whose bottom string starts with 0. That is A and C. If we use C there will a mismatch.
Upper = 1011101 , Bottom = 1011100
So we use A
Upper = 101110 , Bottom = 101110
After using B,A,B,B,B,A from upper 101110 and bottom 101110 is matched but 11011011 is left from upper so we need a pair whose bottom string starts with 1. That is B.
Upper = 10111 , Bottom = 10111
After using B,A,B,B,B from upper 10111 and bottom 10111 is matched but 01101101 is left from upper so we need a pair whose bottom string starts with 0. That is A and C. If we use C there will a mismatch.
Upper = 1011101 , Bottom = 1011100
So we use A
Upper = 101110 , Bottom = 101110
After using B,A,B,B,B,A from upper 101110 and bottom 101110 is matched but 11011011 is left from upper so we need a pair whose bottom string starts with 1. That is B.
We observe that Upper
Values are increasing, we cannot use C having bottom 001 because in upper there
will not 00 in it. So, it is not possible to find a match for this instance.
Question 20: In the silly Post
Correspondence Problem, SPCP, in each pair the top string has the same length
as the bottom string. Show that the SPCP is decidable. 10
Answer: The SPCP problem is decidable. It follows from the following claim.
Claim: A given SPCP instance has a match if and only if there is a domino such that
Proof of the claim:
” ”: If a SPCP instance has a match it has to start with some domino. Because the length of the top and the bottom string is the same in all dominos, the first domino in the match must surely have the same top and bottom string.
” ”: If there is a domino with the same top and bottom string then this single domino forms a trivial match of SPCP.
Answer: The SPCP problem is decidable. It follows from the following claim.
Claim: A given SPCP instance has a match if and only if there is a domino such that
Proof of the claim:
” ”: If a SPCP instance has a match it has to start with some domino. Because the length of the top and the bottom string is the same in all dominos, the first domino in the match must surely have the same top and bottom string.
” ”: If there is a domino with the same top and bottom string then this single domino forms a trivial match of SPCP.
Finally, checking whether there is a domino with the same top
and bottom string is easily decidable by examining the SPCP instance.
Question 22:
Question 22:
Solution:
We can give the number to instances as:
We can give the number to instances as:
We have choice for
start matching that is pair C where 0 is at start from top and bottom so pair C
is,
Form pair c we can see
that 01 is match in top and bottom string but 1 is left in the bottom so we
need a pair whose upper string starts with 1 that is pair A
Now 0110 string is
match from top and bottom,0 is left from bottom so we need a pair, who’s upper
string starts with 0, there are two choice either select pair B or C. Let’s
first try with pair B,
It does not match, so let’s try pair C,
Again we have a mismatch. There is no other pair left. So, it is not possible to find a match for this instance.
Question 23:
Solution:
We can give the number to instances as
Numbering the instances as follows:
Again we have a mismatch. There is no other pair left. So, it is not possible to find a match for this instance.
Question 23:
Solution:
We can give the number to instances as
Numbering the instances as follows:
The dominos
arrangement which will gives the matching of top and bottom string is:
A, B, A, A, B, C, C
A, B, A, A, B, C, C
Now if we note the top
string that is 1001100100100
If we note bottom string that is 1001100100100
Now the matching is found so this list is called match.
If we note bottom string that is 1001100100100
Now the matching is found so this list is called match.
Question 24:
Solution:
We can give the number to instances as :
Solution:
We can give the number to instances as :
We have choice for
start matching that is pair C where 1 is at start from top and bottom so pair C
is,
Form pair c we can see
that 10 is match in top and bottom string but 1 is left in the bottom so we
need a pair whose upper string starts with 1 that is pair D
Now 010 is left from
bottom and we need a string that is start from 0 at the top which is A
Now the matching string is 10101, 0100 is left in the bottom , we need string with 0 from top that is E
now matching string is 101010, 10010 is left in the bottom, so the best choice pair B
matching is 101010100, 100 is left from bottom
So choose pair B again
now 0 is left from bottom so choose pair E
now 10 s left from bottom, choose pair B
Now the matching string is 10101, 0100 is left in the bottom , we need string with 0 from top that is E
now matching string is 101010, 10010 is left in the bottom, so the best choice pair B
matching is 101010100, 100 is left from bottom
So choose pair B again
now 0 is left from bottom so choose pair E
now 10 s left from bottom, choose pair B
So the matching string
is 1010101001000100
Theorem: ALLCFG is un decidable.
If ALLCFG is decidable
then there is a decider R such that L(R) = ALLCFG
Suppose R decides ALLCFG then consider S
1. On input <M, w>
2. Construct and LBA D as described earlier.
3. Convert D into an equivalent CFG G.
4. Run R on G. If R accepts reject. If R rejects accepts.
Suppose R decides ALLCFG then consider S
1. On input <M, w>
2. Construct and LBA D as described earlier.
3. Convert D into an equivalent CFG G.
4. Run R on G. If R accepts reject. If R rejects accepts.
Note that S is a
decider for A TM. A contradiction.
Theorem: HALTTM is un decidable.
Suppose that HALTTM is
decidable and R decides HALTTM. If we have R then we have no problem on TM that
loop endlessly. We can always check if a TM will loop endlessly on a given
input using R. We can use R to make a decider for ATM. We know that ATM is un decidable.
We have a contradiction and that is why R cannot exist.
Given R we can construct S which decides ATM that operates as follows:
Given R we can construct S which decides ATM that operates as follows:
1. On input <M,
w>
2. Run TM R on input <M, w>.
3. If R rejects, reject.
4. If R accepts, simulate M on w until it halts.
5. If M has accepted w, accept; if M has rejected w, reject.
2. Run TM R on input <M, w>.
3. If R rejects, reject.
4. If R accepts, simulate M on w until it halts.
5. If M has accepted w, accept; if M has rejected w, reject.
Note that S will
reject <M, w> even if M loops on w.
No comments: