Unit 5 Toc
Unit 5 Toc
UNIT V - UNDECIDABILITY
Unsolvable Problems and Computable Functions -PCP-MPCP- Recursive and recursively
enumerable languages - Properties - Universal Turing machine -Tractable and Intractable
problems - P and NP completeness - Kruskal's algorithm - Travelling Salesman Problem- 3-
CNF SAT problems.
NO( if W g L)
Loop Forever( if W e L)
prinf(“Halting problem”);
• The above code goes to an infinite loop since the argument of while loop is true forever.
• Thus, if doesn't halts.
• Hence Turing problem is the example for undecidability.
• This concept of solving the halting problem being proved as undecidable was done by Alan Turing in
1936.
• The undecidability can be proved by reduction technique.
Representation of the halting set
The halting set is represented as,
1, if M halts on input w
h(M, w) = f(x) = 0, otherwise
where,
G Turing machine
M
wk Input string
Plaiting HALT
« machine H1
Loop Forever
• Consider, a string describing M and input string, w for M.
• Let HI generates “halt” if HI determines that the Turing machine, M stops after accepting the input, w.
• Otherwise HI loops forever when, M doesn't stops on processing w.
Construction of H2
idaiting HALT
machine H2 Looy
• H2 is constructed with both the inputs being M.
• H2 determines M and halts if M halts otherwise loops forever.
Construction of H3
HALT
Loop
H2 Loop
Halt
• Let H3 be constructed from the outputs of H2.
• If the outputs of H2 are HALT, then H3 loops forever.
• Else, if the output of H2 is loop forever, then H3 halts.
• Thus H3 acts contractor to that of H2.
NO
NO
NO
• Hence M3, M2, M1 halt with either YES or NO on all possible inputs.
• Thus, the union of two recursive languages is also recursive.
UNIT V — UNDECIDAB ILITY
Handled By, P.Dinesh Babu, AP / CPE, V.R.S.College of Engineering & Technology, Arasur Page 7
II CSE CS3452- Theory of Computation
Property - 2: A language is recursive if and only if both it and its complement are recursively enumerable.
Proof:
• Let L and L be two recursively enumerable languages accepted by the Turing machines MI and M2. If a
string, w C L, it is accepted by Ml and Ml halts with answer “YES”. Else M1 enters into infinite loop.
• If a string, w C L [w JL], then it is accepted by M2 and M2 halts with answer “YES”. Otherwise M2 loops
forever.
• The Turing machine, M3 that simulates M1 and M2 simultaneously is given as
W L Ye
E M.
s
RE
w e z• M3 Yes
No
R
eS
L
" “ ' M2
RE
• From the above design of TM, if w C L, if w C L, then M1 accepts w and halts with “YES”.
• If w C L , then M2 accepts w [w C L] and halts with “YES”.
• Since M1 and M2 are accepting the complements of each other, one of them is guaranteed to halt for
every input, w C Z*.
• Hence M3 is a Turing machine that halts for all strings.
M1 M2
W g La No Yes
R R
• Let w C L, then MI accepts w and halts with “YES”.
• M1 rejects w if w C Land halts with “NO”
• M2 is activated once M1 halts.
• M2 works on L and hence if M1 returns “YES”, M2 halts with “NO”.
• If Ml returns “NO”, then M2 halts with “YES”
• Thus for all w, where w C L or w $ L , M2 halts with either “YES” or “NO”
• Hence the complement of a recursive language is also recursive.
Property-4: The union of two recursively enumerable languages is recursively enumerable. Proof:
• Let LI and L2 be two recursively enumerable languages accepted by the Turing machines M1 and M2.
• If a string w C L1 then MI returns “YES”, accepting the input string: Else loops forever.
• Similarly, if a string w C L2 then M2 returns “YES”, else loops forever.
• The Turing machine M3 that performs the union of L1 and L2 is given as
Yes
M1
RE
M3 Yes
RE
Yes
M2
RE
• Here the output of Ml and M2 are written on the input tape of M3.
• The turning machine, M3 returns “YES”, if at least one of the outputs of M1 and M2 is “YES”.
• The M3 decides on L1 U L2 that halts with the answer, “YES” if w C L1 or w C L2.
• Else M3 loops forever if both MI and M2 loop forever.
• Hence the union of two recursively enumerable languages is also recursively enumerable.
II CSE CS3452- Theory of Computation
Let M3 be the Turing machine that is constructed by the intersection of MI and M2, M3 is constructed as
follows.
NO
YES
YES
YES
NO
M1
YES
YEs
M3
—F• Loop Forever
M2
• Thus, M3 decides on L1 n L2 that halts if and only if w C L1 and w C L2. Else M3 loops forever along
with M1 or M2 or both.
• Hence the intersection of two recursively enumerable languages is recursively enumerable.
5.7 POST CORRESPONDENCE PROBLEM
Q7. Explain briefly about Post's Correspondence Problem. [Nov/Dec-2007,2010, May 2013] (Or)
State and prove the Post's Correspondence Problem. [Dec 2012, 2014, 2019] (or)
What is a post corresponding problem (PCP)? Explain with the help of an example. [May/June
2016, Nov/Dec 2019, Apr/May 2021J
• Post Correspondence problem is an undecidable decision problem that was introduced by Emil post in 1946.
• Post correspondence problem known as PCP is an unsolvable combinatorial problem.
• "The Post's correspondence problem consists of two lists of string that are of equal length over the
input. The two lists are A = w1, W2, W3,......, Wn and B = x1, X2, X3,...Xn then there exists a non empty set of
integers ii, i2, i3, .... , In Such that, W1, W2, W3, .... W» * X1, X2, X3,...Xn".
• To solve the post correspondence problem we try all the combinations of ii, iz, Î3,..........., În CO find the w1 =
x1 then we say that PCP has a solution.
Example:
DOMINOsFORM
1. Consider the set of dominos. Does the PCP have a solution?
ab ba b abb a
aba abb ab b bab
Solution:
we need to find a sequence of dominos such that the top and bottom strings are the same.
ab a ba b abb abb b abb
aba bab abb ab b b ab b
ab a ba b abb abb b abb= aba bab abb ab b b ab b
Hence, the PCP has a solution.
TABLE FORM
1. For Z = {a,b} with A = {a, aba3, ab} and B ={a3, ab, b}. Does the PCP with A and B have a solution?
Solution:
The sequence obtained from A and B = (2, 1, 1, 3) as
A solution is 2, 1, 1, 3. That means A2A1A1A3 = &2&1 1 3
The constructed string from both lists is aba3a3b = aba6b
A2 A1 A1 A3
aba3 a a ab
B2 BI BI B3
ab a3 a3 b
10111 10
10
Solution:
Consider the sequence (2, 1, 1, 3)
W2W1W1W3 — X2X IX 1X3
101111110= 101111110
Thus, the PCP has (2,1,1,3) sequence as solution.
3. Consider the correspondence system as given below
A = (b, bab3, ba) and B = (b3, ba, a). The input set is = {0, 1}. Find the solution.
Solution:
A solution is 2, 1, 1, 3. That means wzwlwlW3 = X2X1X1X3
The constructed string from both lists is bab3b3a.
A2 A1 A1 A3
bab3 b b ba
B2 B1 B1 B3
ba b3 b3 a
4. Does PCP with two lists x = (b, a, aba, bb) and y = (ba, ba, ab, b) have a solution?
Solution: Now we have to find out such a sequence that strings formed by x and y are identical. Such a
sequence is 1, 2, 1, 3, 3, 4. Hence from x and y list
1 2 1 3 3 4 1 2 1 3 3 4
b a b aba aba bb = ba ba ba ab ab b
5. Obtain the solution for the following system of posts correspondence problem. A = {ba,abb,bab},
B = {bab, bb, abb}
Solution: Consider the sequence 1, 3, 2. The string obtained from A = babababb. The string obtained from B
= bababbbb. These two strings are not equal. Thus, if we try various combination from both the sets to find
the unique sequence, we could not get such a sequence. Hence there is no solution for this system
6. Let Z = {0,1} A and B are strings. Find instance of PCP.
A B
1 10 101
2 011 11
3 101 011
Solution:
Consider the sequence (1,3,2)
W1W3W2 — X 1X3X2
10101011 /10101111
Thus, the PCP has (1,3,2) sequence has no solution.
7. Obtain the solution for the following system of posts correspondence problem, X = {100, 0, 1}, Y =
{1, 100, 00}.
Solution: The solution is 1, 3, 1, 1, 3, 2, 2. The string is
J1J3J1XiX3'X2X2100 + 1 + 100 + 100 + 1 + 0 + 0 = 1001100100100
1 3 1 1 3 2 2 = 1 + 00 + 1 + 1 + 00 + 100 + 100 = 1001100100100
8. Consider the lists,
a = [b, a, aba, bb]
b = [ba, ba, ab, b]
Solution:
For these 2 lists, the sequence [1, 2, 1, 3, 3, 4] will give the solution for the Post Correspondence Problem. The
String that will be formed in both cases will be “bababaababb” by following the above sequence.
1 2 1 3 3 4 1 2 1 3 3 4
b a b aba aba bb = ba ba ba ab ab b
5.8 THE "MODIFIED" PCP
• It is easier to reduce Lu TO PCP if we first introduce an intermediate version of PCP, which we call it as
Modified Post's Correspondence Problem, or MPCP.
• In the modified PCP, there is the additional requirement on a solution that the first pair on the A and B lists
must be the first pair in the solution.
• More formally, an instance of MPCP is two lists A=w1, w2.... wk and B=x1, x2....xk and a solution is a list
of 0 or more integers i1 ,i2,.....im such that
wi1, wi2..... wim, = xi1, xi2,.....xim.
• Note that the pair (w1, x1) is forced to be at the beginning of the two strings, even though the index 1 is
not mentioned at the front of the list that is the solution.
• Also, unlike PCP, where the solution has to have at least one integer on the solution list, in MPCP, the
empty list could be a solution if wi = xi (but those instances are rather uninteresting and will not figure in
our use of MPCP).
For example consider two lists A and B as
A B
1 11 111
2 100 001
3 111 11
Then the solution is
1 '2 3 X tX2X3
11100111 = 11100111
That means it is essential to have w1 and xi at the beginning of the list.
Proof: To prove that modified PCP is decidable we have to show that PCP is decidable. That is MPCP reduces
to PCP.
While proving this we will consider some instance of MPCP with Z. Then we construct an instance of PCP by
introducing new symbol *. The construction PCP will be done by following method.
- Let we are given an instance of MPCP with lists A = Wl, W2, .... Wk aild B = Xl, X2,....Xk. Now we will insert
new symbols * and $ in Z.
D= z0,zi, .... zk +1 as follows
i. For i = 1, 2, 3,....k. Assign wi = yi * and xi = *zi.
For example, consider
List A List B List C List D
i we xc i yr zi
1 11 111 G 1 1*1* *1*1*1
2 100 001 2 1*0*0* *0*0*1
3 111 11 3 1*1*1* *1*1
ii. NOw assign y0 = * yi and Z0 = Z1. That means first pair and zeroth pair should be same except that zeroth
pair has extra * at the beginning of the string from first list. Whereas from the second list zeroth and first
pair must be the same.
For example, consider
List C List D List C List D
i yr zi i yr zi
0 *1*1* *1*1*1
1 1*1* *1*1*1 1 1*1* *1*1*1
2 1”0”0* *0*0*1 2 1”0”0” ”0”0*1
3 1”1”1* *1*1 3 1”1”1” ”1*1
v. But since y0 = * yi and zo = zi we can fix the initial * by replacing first index by 0 then we have
yo yr yi1 .... y; = zo zi zi1, zim*.
For example,
yo y2 y3
*1*1* 1*0*0* 1*1*1*
ZO Z2 Z3
*1*1*1 *0*0*1 *1*1
yo yz y3 = z0 Z2 Z3 *.
*1*1* 1*0*0*1*1*1* = * 1*1*1*0*0*1*1*1*
vi. Now we can take care of final * by appending the index k + 1. i.e. yk + i = $ and Zk +1 = * $. Then we have
y0 yr yi1 .... you yk + i = zo zi zi1,....zim Zk +1•
For example,
y0 y2 y3 y4
*1*1* 1*0*0* 1*1*1* $
Z0 ZZ Z3 Z4
*1*1*1 *0*0*1 *1*1 *$
yo yz y3 yr = Z0 z2 z3 Z4
*1*1* 1*0*0*1*1*1*$ = * 1*1*1*0*0*1*1*1*$
Thus 0, ii,12,....i+, k +1 has a solution to the instance of PCP.
vii. Similarly we can show that if constructed instance of PCP has a solution, then original MPCP also have a
solution. The solution of PCP must begin with index 0 and end with index k + 1. Thus solution to PCP can be
0, ii, iz, .... i+, k +1. We can claim that i1,12, i+ is a solution to the instance of PCP. (i.e. remove * $ and $
from
the strings)
So, for PCP
y0 y1 yil .... yim yk + 1 = Z0 zl zi1,......Ztm Zk + 1.
which follows that w1 Wi1 wi2 ..... Wim - X1 Xil Xi2......Xim
Thus a solution to the PCP instance implies a solution to MPCP instance. Hence reduction of MPCP to PCP
confirms that if PCP were decidable then MPCP would also be decidable.
Example:
1. Let A= {001, 0011, 11, 101} and B={01, 111, 111, 010}. Does a pair (A,B) have post correspondence (PC)
solution? Does the pair (A,B) have modified posts correspondence (MPC) solution?
Solution: The solution can be (3,4,1) ie a3 a4 a1 = b3 b4 bi 11101001
= 11101001
Consider
List A List B List C List D
i yi z;
1 001 01 1 0*0*1* *0*1
2 0011 111 2 0*0*1*1* *1*1*1
3 11 111 3 1*1* *1*1*1
4 101 010 4 1*0*1* *0*1*0
Assign y0 = * yi and Z0 = Z1
List C List D
i yr zi
0 *0*0*1* *0*1
1 0*0*1* *0*1
2 0*0*1*1* *1*1*1
3 1*1* *1*1*1
4 1*0*1” ”0”1”0
Now construct the last pair yk • i aild Zk • i put yk + 1= $ and zk + 1= * $
List C List D
i yr zi
0 *0*0*1* *0*1
1 0*0*1* *0*1
2 0*0*1*1* *1*1*1
3 1*1* *1*1*1
4 1*0*1* *0*1*0
5 $ *$
If * y0, yi, y2, y3 ..... yk = zo,z1, Z2, Z3 ..... Zk * the MCP has solution. Consider the solution (3, 4,1,5) then
* y3 y4 yr= Z3 Z4 Z1
i.e *1*1*1*0*1*0*0*1* = *1*1*1*0*1*0*0*1* is solution.
2. State whether the instances of the post correspondence problem (PCP) have a solution. The
following are the instances with Z = {0,1} [Nov/Dec 2022]
Index List A List B
1 10 01
2 110 011
3 110 01
4 000 00
5 10 010
In case the PCP has a solution, describe the post correspondence solution with justification. Solution:
Step 1: Start with tile in which numerator and denominator are starting with same number, so we can start with
tile 4. String made by numerator and denominator is
A4 000
&4 00
Step 2: We need 0’s in denominator to match 0’s in numerator. So we will go with tile 2. String made by
numerator and denominator is
A4A2 000110
4 2 00011
Step 3: We need 0’s in denominator to match 0’s in numerator. We will go with tile 1. String made by
numerator and denominator is
A4A2 AI 00011010
B4B2 Al 0001101
Step 4: There is extra 0’s in numerator to match this with 0 in denominator. We will add tile 5. String made by
numerator and denominator is
A4A2 A1 A5 000110 1010
B4B2 Al 5 000110 1010
Thus PCP sequence (4, 2, 1, 5) has a solution.
String made by numerator: 0001101010 String
made by denominator: 0001101010
MPCP
The solution can be (4, 2, 1, 5) ie a4 a2 a1 a5' b4 b2 bi b5
0001101010 = 0001101010
i. For i = 1, 2, 3, ... k. Assign wi = yi * and xi = *zi.
Index List A List B Index List C List B
wi x; y; z;
1 10 01 1 1*0* *0*1
2 110 011 2 1*1*0* *0*1*1
3 110 01 3 1*1*0* *0*1
4 000 00 4 0*0*0* *0*0
5 10 010 5 1*0* *0*1*0
Assign yo = * yi and zo = zi
Index List C List D
yi zi
0 *1*0* *0*1
1 1*0* *0*1
2 1*1*0* *0*1*1
3 1*1*0* *0*1
4 0*0*0* *0*0
5 1*0* *0*1*0
Now construct the last pair yk + i and zk + i put yk + i = $ arld Zk +1 = * $
Index List C List D
yr zi
0 *1*0* *0*1
1 1*0* *0*1
2 1*1*0* *0*1*1
3 1*1*0* *0*1
4 0*0*0* *0*0
5 1*0* *0*1*0
6 $ *$
If * y0, yi, y2, y3 ..... yk = zo,z1, z2, Z3..zk * the MCP has solution. Consider the solution (4, 2, 1, 5) then
* y4 y2 y1 ys= z4 Z2 Z1 z5
i.e *0*0*0*1*1*0* 1*0*1*0* = *0*0*0*1*1*0* 1*0*1*0* is solution.
• Undecidability of a problem means that there is no particular algorithm that can determine whether a given
problem has a solution or not.
• A common undecidable problem is a Turing problem, so its undecidability is also proved if we can
reduce the Turing problem into post Correspondence problem.
• Consider an instance of a post correspondence problem that can simulate the computation of an
arbitrary Turing Machine on random input.
• A match will occur if the Turing machine accepts the input.
• The problem of deciding whether a Turing machine will accept the given information or not is a well -
known problem.
• As the post Correspondence problem reduces to this particular problem, we can say the post
correspondence problem is undecidable, which completes our proof.
Theorem: To prove PCP is undecidable
Proof:
• It is sufficient to show that if MPCP were decidable, then PCP would be decidable whether a TM accepts a
given word.
• We reduce Lu TO MPCP, which again can be reduced to PCP.
• For each M and w1, we construct an instance of MPCP that if it has a solution has one starts with
#q0w#aiqi§i#......# akqkbk
where
- Strings between successive #’s are successive ID's in a computation of M with input w.
- qk is the final state.
Solution:
Consider a Turing machine M to simulate this PCP's input string w can be represented as <M, w>.
M = (qz,r,6,q0,qaccept,qreject)
Approach:
• Take a problem that is already proven to be undecidable and try to convert it to PCP.
• If we can successfully convert it to an equivalent PCP then we prove that PCP is also undecidable.
Acceptance Problem of a Turing Machine (This is an undecidable problem)
q1
Z={a,b}
r ={a,b,X,B}
w=aba
qoaba
s q0 aba#
Step 2:
6 (q0,a)= (q1, X,R)
bra B
q1
qoa=Gxqi q0 a
x q1
Step 3:
6 (qi,b)= (q2,
X,L)
bra B a B
q2
y C r, where r =(a,b,X,B}
y qi b= q2yX
a q1 b b q1 b X q1 B q1 b
b
q2 a X q2 b X q2 X q2 B X
X
Step 5: For all possible tape symbols after reaching the accepting state q2.
a q2 q2 a b q2 q2 b X q2 B q2 q2 B
q2 X
q2 q2 q2 q2 q2 q2 q2 q2
# B#
UNIT V — UNDECIDAB ILITY
Handled By, P.Dinesh Babu, AP / CSE, V.R.S.College of Engineering & Technology, Arasur Page 18
II CSE CS3452- Theory of Computation
f# q2 X X a#J f q2 X a f#
f#q2 X a#J f q2 a f#
# q2 ##J
Proof: The algorithm of this theorem should be designed in such a way that it converts an input that is
binary coded pair (M,w) into a Turing Machine Ml. Such that L(MI) = Q if and only if M accepts input w.
Yes Yes
It is clear that the below table tells for all i and j, whether the Turing Machine Mi accepts input string Wjl
• if (i,j)= 1 means "yes it is accepted" and
• if (i,j)= 0 means "no it doesn't" accepted or rejected.
We may think of the ith row as the characteristic vector for the language L(Mi); that is, the 1's in this row
indicate the strings that are members of this language.
l 2 3 4 ”’
2 0 0
3 0 0
4
—> Reject
TM M' for Ld
• We define Lu, the universal language, to be the set of binary strings that encode, a pair (M, w), where M is
a TM with the binary input alphabet, and w is a string in (0+1)*, such that w is in L(M).
• That is, Lu is the set of strings representing a TM and an input accepted by that TM.
• We shall show that there is a TM U, often called the universal Turing machine, such that, Lu = L(U). Since
the input to U is a binary string, U is in fact some M in the list of binary-input Turing machines.
• It is easiest to describe U as a multitape Turing machine.
Tape of 3f 000l00tD0I0l00Ol
• The transitions of M are stored initially on the first tape, along with the string w.
• A second tape used to hold the simulated tape of M, using the same format as for the code of M. That is,
tape symbol Xi of M will be represented by 0i, and tape symbols will be separated by single l's.
• The third tape holds the state of M, with state qi where i is represented by 0's.
• The UTM is a recognizer but not a decider.
The operation of U can be summarized as follows:
1. The first tape is observed carefully to check whether the code for M is Valid or not. If the code is not valid
then UTM halts without accepting.
2. Initialize the second tape for placing the tape values of M in encoded form i.e.
- for each 0 of w place 10 on 2n* tape
- for each 1 of w place 100 on 2nd tape
- for each Blank letters (B) of w place 100 on 2n* tape. (Blanks will not actually appear on that tape)
3. 3r*tape stores state of machine M, place 0, the start state of M, on the third tape, and move the head of U's
second tape to the first simulated cell.
4. To simulate a move of M, U searches on its first tape for a transition 0i10j10k1010
Where
G 0i current state (tape 3)
0j current input tape symbol (tape 2)
0kO changed state
For example:
Consider an example of sudo-ku game. In order to solve this entire puzzle, the algorithm would have to
check each 3 X 3 matrix to see which numbers are missing then each row, then each column and then make
sure there are no repetitions of any digit from 0 — 9. This becomes more complex because the number of digits
that are missing is inconsistent in each row, column and matrix. Solving this problem is not possible in
polynomial time. But once we get the solution, then verifying this solution is possible within very less time.
Thus verification of solution of this problem is possible in polynomial time.
Computational
complexity problems
NP class
NP complete NP hard
• The NP class problems can be further categorized into NP complete and NP hard Problems.
NP
a e d
Total Weight = 13
Action of Kruskal's algorithm
Edge Weight Action
(e,g) 1 ACCEPTED
(a,e) 2 ACCEPTED
(e,f) 2 ACCEPTED
(e,c) 2 ACCEPTED
(b,c) 3 ACCEPTED
(c,d) 3 ACCEPTED
(d,g) 3 REJECTED
2 3
• The tour path will be a-b-d-e-c-a and total cost of tour will be 16.
• This problem is NP problem as there may exist some path with shortest distance between the cities.
• If you get the solution by applying certain algorithm then travelling salesman problem is NP com plete
problem.
• If we get no solution at all by applying an algorithm then the travelling salesman belongs to NP hard
class.
5.14.4 Difference between P and NP class
P NP
An algorithm in which for given input the An algorithm is called non deterministic
definite output gets generated is called polynomial time algorithm (NP class) when for
polynomial time algorithm (P class) given input there are more than one paths that the
algorithm can follow. Due to which one cannot
determine which path is to be followed after
particular stage.
Time is fixed. Time is not fixed.
In polynomial time, the input is fixed. In NP, the input is not fixed.
Use a deterministic Turing machine They can only be solved deterministically in
exponential time
Every problem which is a P class is also in NP Every problem which is in NP class is not in the P
class. class.
The process is fixed. The process is not fixed.
Fig: Reducing circuit satisfiability to formula satisfiability. The formula produced by the reduction
algorithm has a variable for each wire in the circuit.
circuit would have the corresponding formula
x4 = x3
x5 = (x1 V x2)
x6 = x4
x7 = (x1 A x2 A
x4) x8 = (x5 V x6)
x9 = (x6 V x7)
x10 = (x7 A x8 A x9)
f -- x5 A x4 A x6 A x7 A x8 A x9 A x10
Thus if we could solve the Boolean satisfiability problem in polynomial time, we could solve the circuit
satisfiability problem in polynomial time (and by extension any NP problem in polynomial time). Hence SAT is
also an NP complete problem.
5.16 3-CNF SATISFIABILITY
Q19. Prove that 3 -SAT problem is NP complete. |
• If the Boolean expression consists of exactly 3 OR ’ed variables per clause with all the clauses being
AND'ed, then the expression is said to be in 3-CNF form (conjunctive normal form).
Problem
• Given a 3-CNF expression, find an assignment of the literals that satisfies the expression, i.e., causes the
expression to evaluate to 1. It can be shown that 3-CNF is also NP-complete by reducing general
Boolean satisfiability to 3-CNF.
Proof
• The reduction is performed in three steps:
Step 1: Convert clauses into a binary parse tree
• Since each Boolean operator is a binary operator, we simply construct a binary parse tree where the
nodes are the operators and the literals are leaves.
• In the case of clauses with multiple literals, we simply add associative parentheses as needed to make
binary clauses.
X1 Xg
Thus the original expression can be rewritten (by traversing the parse tree) as
‹p' = y1 A ( y1 w ( y2 A x2 ))
A ( y2 w ( y3 V y4 ))
A ( y3 w ( x1 —+ x2 ))
A ( y4 w ( y5 ))
A ( y5 w ( y6 V x4 ))
A ( y6 w ( x1 w x3 ))
Step 2: Convert each clause to CNF
Constructing the truth table for the first clause ‹p'1 = (y1 w (y2 A x2)) gives
yi y2 xz (y1 w (y2 A X2))
0 0 0 1
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 0
• Thus we can write ‹p'1 by simply AND'ing the literals (negating any false values) for each row that
evaluates to 0 and 0R'ing all the 0 rows (i.e. sum-of-products) giving
‹p'1 = ( y1 A y2 A x2) V ( y1 A y2 A x2) V ( y1 A y2 A x2) V ( y1 A y2 A x2)
Loop Forever( if W g L)
4. When a problem is said to be decidable and give an example of undecidable problem. [Nov/Dec-
2003,20 12, 2015, May-06,05]
A problem whose language is recursive is said to be decidable. Otherwise, the problem is undecidable. The
class of problems which can be answered as “Yes” are called solvable or decidable. The class of problems which
can be answered as “No” are called undecidable problems.
Following are undecidable problems.
i)Whether the language accepted by a TM is empty.
ii) Whether the language accepted by a TM is regular language.
iii)Whether the language accepted by a TM is context free language.
5. When we say a problem is decidable (Or) Define Decidable Problem?
A problem whose language is recursive is said to be decidable. Otherwise the problem is said to be
undecidable. Decidable problems have an algorithm that takes as input an instance of the problem and
determines whether the answer to that instance is “yes” or “no”.
6. Mention the example of Decidable Problems.
Here are some examples of decidable problems:
• Given a mathematical statement, determine whether it is true or false.
• Checking whether a given string is a palindrome.
• Determining whether a number is even or odd.
• Checking whether a given graph is connected.
• Verifying whether a given regular expression matches a string.
M halts on w
Input AC £!'
String(w) ’ "
Turning
M doesnot halt on W
Machine Reject
• There is a Turning Machine (M), over an alphabet Z(a,b), the problem is : does M halt when it is given w
as an input string.
• A halting problem is undecidable.
14. What are some other well-known undecidable problems related to a Turing Machine?
The Membership, Finiteness, and Emptiness of a Turing Machine are all well-known undecidable
problems related to a Turing Machine.
15. When a language is said to be recursive? Is it true that every regular set is not recursive?
[Nov/Dec 2005, Apr/May 2021]
• A language L is said to be recursive if there exists a Turing machine M that accepts every string of the
language L, and goes to halt state or else rejects those strings that are not in the language L.
• If the input is accepted, M halts with the answer,” YES”
• w C L the Turing machine doesn't accept the string.
• If w C L, then M halts with answer, “NO”.
• The recursive languages are called Turing decidable languages
• Recursive language will halt on every input.
TM Accept
Input String
Reject
EYES (i fW E L)
Input String TM
Loop Forever( if w e L)
TM Accept
Input String
Reject
Non Recursive language
A language L is non recursive, if L is the set of strings not accepted by Turing Machine.
24. Define Non Recursively enumerable language.
If the language L is not recursively enumerable, then there is no algorithm for listing the members of
L. It might be possible to define L by specifying some property that all its members satisfy, but that property can't
be computable.
25. What are Recursive sets? [Nov/Dec-13]
A language is said to be recursive if there exists a turing machine that accepts the strings belonging to
that language and rejects on every string that are not belonging to that language. Every regular set is not
recursive.
26. What properties of recursive enumerable sets are not decidable?
What are the properties of recursively enumerable sets which are undecidable?
o Emptiness
o Finiteness
o Regularity
o Context-freedom.
27. Sate two languages, which are not recursively enumerable. [Dec-09]
Diagonalization language is not recursively enumerable.
The partially decidable languages or undecidable languages are not recursively enumerable.
M1 M2
W e La No Yes
R R
• Let w C L, then Ml accepts w and halts with “YES”.
• Ml rejects w if w $ Land halts with “NO”
• M2 is activated once M1 halts.
• M2 works on L and hence if M1 returns “YES”, M2 halts with “NO”.
• If Ml returns “NO”, then M2 halts with “YES”
• Thus for all w, where w C L or w $ L , M2 halts with either “YES” or
“NO” Hence the complement of a recursive language is also recursive
30. What is Church's Hypothesis?
The notion of computable function can be identified with the class of partial recursive functions is
known as Church-hypothesis or Church-Turing thesis. The Turing machine is equivalent in computing
power to the digital computer.
31. State Post's correspondence problem. [Nov-Dec 2021] (or)
Define PCP or Post Correspondence Problem.
• "The Post's correspondence problem consists of two lists of string that are of equal length over the input
The two lists are A = w1, W2, W3,....., Wn aild B = Xl, X2, X3,..Xn then there exists a non empty set of integers
11, 12, 13, .... , In Such that, W1, W2, W3, .... Wn * X1, X2, X3,...Xn".
• To solve the post correspondence problem we try all the combinations of i1, 12, 13,..........., ln TO find the w1 =
x1 then we say that PCP has a solution.
32. Define MPCP or Modified PCP.
• It is easier to reduce Lu TO PCP if we first introduce an intermediate version of PCP, which we call it as
Modified Post's Correspondence Problem, or MPCP.
It is clear that the below table tells for all i and j, whether the Turing Machine Mi accepts input strifl Wj:
• if (i,j)= 1 means "yes it is accepted" and
• if (i,j)= 0 means "no it doesn't" accepted or rejected.
We may think of the ith row as the characteristic vector for the language L(M;); that is, the 1's in this row
indicate the strings that are members of this language.
47. What are the features of Universal Turing machine? [May 2007]
Following are the features of Universal Turing machine (UTM).
Universal Turing machine is a kind of turing machine can simulate any other turing machine. In other
words, UTM is a single machine used to compute any computable sequence.
Another interesting feature of UTM is that it has an ability to manipulate an unbounded amount of data
in finite amount of time.
48. What are the concepts used in UTMs?
• Stored program computers.
• Interpretive Implementation of Programming languages.
• Computability.
49. What are the two classes of problems that are solved by the Turing machine?
The two classes of problems that can be solved by the Truing machines are as follows.
1. Those problems that have an algorithm
2. Those that are only solved by Turing machine.
50. What is the weak-form of Turing thesis?
A Turing Machine can compute anything that can be computed by a general purpose digital computer.
51. What is the strong-form of Turing thesis?
A Turing Machine can compute anything that can be computed. This is the strong form of Turing thesis.
52. What are the reasons for a TM not accepting its input?
i) The TM may halt in a non final state.
ii) The TM may enter into an indefinite loop.
53. Give the difference between Turing Machine and Universal Turing Machine.
Turing Machine Universal Turing Machine
1. It is a mathematical model of computation it Universal Turing Machine is like a single Turing
manipulates symbols on the tape according Machine that has a solution to all problem that is
to the rules defined computable
2. A program can be compared to a Turing Programmable Turing Machine is called Universal
Machine Turing Machine
3. Turing machine's temporary storage is tape. Universal Turing Machine contains Turing Machine
The infinite cells of the Turing machine can description as input along with an input string, runs
contain input symbols and blanks. the Turing Machine on the input and returns the
result.
4. Turing machines help us understand the Although developed for theoretical reasons, it
fundamental limitations of mechanical helped in the development of stored program
computation power computers
5. A Turing machine is a formal model of a Universal Turing Machine provides a solution to
computer with a fixed program problems that are computable
6. It does not minimize the space complexity It minimizes space complexity