Unit 5 Toc
Unit 5 Toc
UNDECIDABILITY
UNDECIDABILITY
Recursive Language
● Assume the states are q1,q2…,qr for some r. The start state will
● Assume the states are q1,q2…,qr for some r. The start state will always
● Assume the tape symbols are X1,X2,...Xs for some s. X1 always will be
C111C211… Cn-111Cn
If wi is not a valid TM code, we shall take Mi to be the TM with one state and no transitions.
That is, for these values of i, Mi is a Turing machine that immediately halts on any input.
Theorem : Ld is not a recursively enumerable language That is, there is no Turing machine that accepts L d.
PROOF:
● Suppose Ld were L(M) for some TM M.
● Since Ld is a language over alphabet {0,1}, would be in the list of Turing machines we have
Theorem : Ld is not a recursively enumerable language That is, there is no Turing machine that accepts Ld.
PROOF:
● If wi is in Ld, then Mi accepts wi. But then, by definition of Ld, wi is not in Ld, because Ld contains only
● Similarly, if wi is not in Ld, then Mi does not accept wi. Thus, by definition of Ld, wi is in Ld.
Since wi can neither be in Ld nor fail to be in Ld. we conclude that there is a contradiction of our assumption
1. Recursive language
2. Recursive Enumerable
language
3. Universal language
AN UNDECIDABLE PROBLEM THAT IS RE
Recursive language
A language L recursive if L = L(M) for some
Turing machine M such that:
1. If w is in L, then M accepts (and therefore
halts)
2. If w is not in L, then M eventually halts,
although it never enters an accepting state
AN UNDECIDABLE PROBLEM THAT IS RE
Recursive language
A language L recursive if L = L(M) for some
Turing machine M such that:
1. If w is in L, then M accepts (and therefore
halts)
2. If w is not in L, then M eventually halts,
although it never enters an accepting state
AN UNDECIDABLE PROBLEM THAT IS RE
L is recursive.
PROOF
● Neither L nor L’ is RE
ie, both are in the outer
ring
AN UNDECIDABLE PROBLEM THAT IS RE
● L is RE but not
recursive, and L’ is not
RE ie, one is in the
middle ring and the
other is in the outer ring
AN UNDECIDABLE PROBLEM THAT IS RE
● L’ is RE but not
recursive, and L is not
RE; ie, the same as
above) but with L and L’
swapped.
The universal language
The Universal Language
A single TM can be used as a stored program computer, taking its program as
well as its data from one or more tapes on which input is placed
The Universal Language
● We define Lu, the universal language, to be the set of binary strings that
encode, in the notation of 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 LM.
● 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)
The Universal Language
It is easiest to describe U as a multitape Turing machine.
In the case of U, the transitions of M are stored initially on the first tape, along
with the string w.
A second tape will be 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 1’s.
The third tape of U holds the state of M, with state qi represented by i’s.
The Universal Language
The Universal Language
The operation of U can be summarized as follows
1. Examine the input to make sure that the code for M is a legitimate code for
some TM. If not, U halts without accepting. Since invalid codes are assumed
to represent the TM with no moves, and such a TM accepts no inputs, this
action is correct.
The Universal Language
The operation of U can be summarized as follows
2. Initialize the second tape to contain the input w, in its encoded form. That is, for
each 0 of w, place 10 on the second tape, and for each 1 of w, place 100 there.
Note that the blanks on the simulated tape of M, which are represented by 1000, will
not actually appear on that tape; all cells beyond those used for w will hold the blank of
U.
However, U knows that, should it look for a simulated symbol of M and find its own
blank, it must replace that blank by the sequence 1000 to simulate the blank of M
The Universal Language
The operation of U can be summarized as follows
3. 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
The Universal Language
The operation of U can be summarized as follows
a) Change the contents of tape 3 to 0k; that is, simulate the state change of M
To do so, U first changes all the 0’s on tape 3 to blanks, and then copies 0 k
from tape 1 to tape 3.
b) Replace 0j on tape by 0l; that is, change the tape symbol of M. If more or less
space is needed (i.e., i ≠ l) , use the scratch tape and the shifting over
technique to manage the spacing.
c) Move the head on tape 2 to the position of the next 1 to the left or right,
respectively, depending on whether m =1 (move left) or m = 2 (move right).
Thus, U simulates the move of M to the left or to the right
The Universal Language
4. If M has no transition that matches the simulated state and tape symbol, then in
(4), no transition will be found Thus, M halts in the simulated configuration and U
must do likewise.
Ld is not a recursively enumerable language That is, there is no Turing machine that
accepts Ld. we conclude that Lu is not recursive
Undecidable Problems About Turing Machines
Reductions
Theorem:
If there is a reduction from P1 to P2, then:
If L(Mi) = Ø, that is, Mi does not accept any input, then w is in Le.
On the other hand, if L(Mi) is not the empty language, then w is in Lne.
Thus, Lne is the language of all codes for Turing machines that accept at least one
input string
Undecidable Problems About Turing Machines
Turing Machines That Accept the Empty Language
● Le = { M | L(M) = Ø}
● Lne = { M | L(M) ≠ Ø}
Notice that Le and Lne are both languages over the binary alphabet {0,1}.
Undecidable Problems About Turing Machines
Turing Machines That Accept the Empty Language
Theorem : Lne is recursively enumerable
PROOF:
We have only to exhibit a TM that accepts L ne.
The operation of M is as follows
1. M takes as input a TM code Mi.
2. Using its nondeterministic capability, M guesses an input w that M i might
accept.
3. M tests whether Mi accepts w.
4. If Mi accepts w, then M accepts its own input, which is M i
Undecidable Problems About Turing Machines
Turing Machines That Accept the Empty Language
Theorem : Le is not RE
Undecidable Problems About Turing Machines
Turing Machines That Accept the Empty Language
That is w2w1w1w3=x2x1x1x3
Post’s Correspondence Problem
For instance, let m=4, i1=2,i2=1,i3=1 and i4=3
That is w2w1w1w3=x2x1x1x3
101111110
Post’s Correspondence Problem
For instance, let m=4, i1=2,i2=1,i3=1 and i4=3
That is w2w1w1w3=x2x1x1x3
101111110
Post’s Correspondence Problem
Give an instance of PCP, tell whether this instance has a solution.
Post’s Correspondence Problem
The Modified PCP
w1wi1wi2...,wim = x1xi1xi2...,xim
Post’s Correspondence Problem
The Modified PCP
We are given an instance of MPCP with lists A=w1,w2,...,wk and B=x1,x2,...xk,
for some integer k.
Post’s Correspondence Problem
The Modified PCP
We are given an instance of MPCP with lists A=w1,w2,...,wk and B=x1,x2,...xk,
for some integer k.
We assume * and $ are symbols not present in the alphabet Σ of this MPCP
instance .
Post’s Correspondence Problem
The Modified PCP
We are given an instance of MPCP with lists A=w1,w2,...,wk and B=x1,x2,...xk,
for some integer k.
We assume * and $ are symbols not present in the alphabet Σ of this MPCP
instance .
We construct a PCP instance C=y0,y1,...,yk+1 and D=z0,z1,...zk+1 , as follows:
Post’s Correspondence Problem
The Modified PCP
We construct a PCP instance C=y0,y1,...,yk+1 and D=z0,z1,...zk+1 , as follows:
1. For i = 1,2,...,k, let yi be wi with a * after each symbol of wi ,and let zi be xi with
a * before each symbol of xi.
Post’s Correspondence Problem
The Modified PCP
We construct a PCP instance C=y0,y1,...,yk+1 and D=z0,z1,...zk+1 , as follows:
1. For i = 1,2,...,k, let yi be wi with a * after each symbol of wi ,and let zi be xi with
a * before each symbol of xi.
2. y=*y1, and z0=z1.
Post’s Correspondence Problem
The Modified PCP
We construct a PCP instance C=y0,y1,...,yk+1 and D=z0,z1,...zk+1 , as follows:
1. For i = 1,2,...,k, let yi be wi with a * after each symbol of wi ,and let zi be xi with
a * before each symbol of xi.
2. y=*y1, and z0=z1.
3. yk+1= $ and zk+1=$
Post’s Correspondence Problem
The Modified PCP
We construct a PCP instance C=y0,y1,...,yk+1 and D=z0,z1,...zk+1 , as follows:
1. For i = 1,2,...,k, let yi be wi with a * after each symbol of wi ,and let zi be xi with
a * before each symbol of xi.
2. y=*y1, and z0=z1.
3. yk+1= $ and zk+1=$
Post’s Correspondence Problem
The Modified PCP
We construct a PCP instance C=y0,y1,...,yk+1 and D=z0,z1,...zk+1 , as follows:
1. For i = 1,2,...,k, let yi be wi with a * after each symbol of wi ,and let zi be xi with
a * before each symbol of xi.
2. y=*y1, and z0=z1.
3. yk+1= $ and zk+1=$
Post’s Correspondence Problem
Theorem: MPCP reduces to PCP
Post’s Correspondence Problem
Reducing Lu to MPCP
Given a pair (M,w), we construct an instance (A,B) of MPCP such that TM M
accepts input w if and only if (A,B) has a solution
Post’s Correspondence Problem
Reducing Lu to MPCP
Let M=(Q,Σ,Γ,δ,q0,B F) be a TM and let w in Σ* be an input string.
We construct an instance of MPCP as follows
Post’s Correspondence Problem
Reducing Lu to MPCP
Let M=(Q,Σ,Γ,δ,q0,B F) be a TM and let w in Σ* be an input string.
We construct an instance of MPCP as follows
1. The first pair is
List A List B
# #q0w#
Post’s Correspondence Problem
Reducing Lu to MPCP
Let M=(Q,Σ,Γ,δ,q0,B F) be a TM and let w in Σ* be an input string.
We construct an instance of MPCP as follows
1. The first pair is
List A List B
# #q0w#
2. Tape symbols and the separator # can be appended to both lists. The pairs
List A List B
X X for
each X in Γ
# #'
Post’s Correspondence Problem
Reducing Lu to MPCP
Let M=(Q,Σ,Γ,δ,q0,B F) be a TM and let w in Σ* be an input string.
We construct an instance of MPCP as follows
1. The first pair is
List A List B
# #q0w#
2. Tape symbols and the separator # can be appended to both lists. The pairs
List A List B
X X for each X
in Γ
# #'
3. To simulate a move of M, we have certain pairs that reflect those moves. For all q in Q-F(ie, q is a
nonaccepting state), p in Q, and X, Y and Z in Γ we have:
List A List B
qX Yp if δ(q,X)=(p,Y,R)
ZqX pZY if δ(q,X)=(p,Y,L); Z is
any tape symbol
q# Yp# if δ(q,B)=(p,Y,R)
Zq# pZY# if δ(q,B)=(p,Y,L); Z is any
tape symbol
Post’s Correspondence Problem
Reducing Lu to MPCP
Let M=(Q,Σ,Γ,δ,q0,B F) be a TM and let w in Σ* be an input string.
We construct an instance of MPCP as follows
4. if q is an accepting state, then for all tape symbols X and Y, there are pairs:
List A List B
XqY q
Xq q
qY q
5. Finally, once the accepting state has consumed all tape symbols
List A List B
q## #
Post’s Correspondence Problem
Reducing Lu to MPCP
Let us convert TM
We must start with the first pair, (start state q 1 and input 01) as required in any solution to MPCP
A:#
B:#'q101#'
Post’s Correspondence Problem
Reducing Lu to MPCP
2. Tape symbols and the separator # can be appended to both lists. The pairs
List A List B
X X for
each X in Γ
# #'
Post’s Correspondence Problem
Reducing Lu to MPCP
2. Tape symbols and the separator # can be appended to both lists. The pairs
List A List B
X X for
each X in Γ
# #'
Post’s Correspondence Problem
Reducing Lu to MPCP
3.To simulate a move of M, we have certain pairs that reflect those moves. For all q in Q-F(ie, q is a nonaccepting state), p
in Q, and X, Y and Z in Γ we have:
List A List B
qX Yp if
δ(q,X)=(p,Y,R)
ZqX pZY if δ(q,X)=(p,Y,L); Z is
any tape symbol
q# Yp# if
δ(q,B)=(p,Y,R)
Zq# pZY# if δ(q,B)=(p,Y,L); Z is any
tape symbol
Post’s Correspondence Problem
Reducing Lu to MPCP
3.To simulate a move of M, we have certain pairs that reflect those moves. For all q in Q-F(ie, q is a nonaccepting state), p
in Q, and X, Y and Z in Γ we have:
List A List B
qX Yp if
δ(q,X)=(p,Y,R)
ZqX pZY if δ(q,X)=(p,Y,L); Z is
any tape symbol
q# Yp# if
δ(q,B)=(p,Y,R)
Zq# pZY# if δ(q,B)=(p,Y,L); Z is any
tape symbol
Post’s Correspondence Problem
Reducing Lu to MPCP
4. if q is an accepting state, then for all tape symbols X and Y, there are pairs:
List A List B
XqY q
Xq q
qY q
Post’s Correspondence Problem
Reducing Lu to MPCP
4. if q is an accepting state, then for all tape symbols X and Y, there are pairs:
List A List B
XqY q
Xq q
qY q
Post’s Correspondence Problem
Reducing Lu to MPCP
5. Finally, once the accepting state has consumed all tape symbols
List A List B
q## #
Post’s Correspondence Problem
Reducing Lu to MPCP
5. Finally, once the accepting state has consumed all tape symbols
List A List B
q## #
The Classes P and NP
The Classes P and NP
Problems Solvable in Polynomial Time
A Turing machine M is said to be of time complexity T(n) [or to have running time T(n)], if
wheneverM is given an input w of length n, M halts after making at most T(n) moves,
regardless of whether or not M accepts.
A minimum weight spanning tree has the least possible total edge weight of all spanning
trees
The Classes P and NP
Problems Solvable in Polynomial Time (An Example Kruskal’ Algorithm)
There is a well-known greedy algorithm, called Kruskal’s Algorithm, for finding a MWST
The Classes P and NP
Problems Solvable in Polynomial Time (An Example Kruskal’ Algorithm)
There is a well-known greedy algorithm, called Kruskal’s Algorithm, for finding a MWST
The Classes P and NP
Problems Solvable in Polynomial Time (An Example Kruskal’ Algorithm)
There is a well-known greedy algorithm, called Kruskal’s Algorithm, for finding a MWST
The Classes P and NP
roblems Solvable in Polynomial Time (An Example Kruskal’ Algorithm)
P
100
The Classes P and NP
Problems Solvable in Polynomial Time (An Example Kruskal’
Algorithm)
Let us consider a possible code for the graphs and weight limits
that could be the input to the MWST problem. The code has five
symbols, 0,1,the left and right parentheses, and the comma
100,101000
The Classes P and NP
Problems Solvable in Polynomial Time (An Example Kruskal’
Algorithm)
Let us consider a possible code for the graphs and weight limits
that could be the input to the MWST problem. The code has five
symbols, 0,1,the left and right parentheses, and the comma
100,101000(1,10,1111)
The Classes P and NP
Problems Solvable in Polynomial Time (An Example Kruskal’
Algorithm)
Let us consider a possible code for the graphs and weight limits
that could be the input to the MWST problem. The code has five
symbols, 0,1,the left and right parentheses, and the comma
100,101000(1,10,1111)(1,11,1010)(10,11,1100)
(10,100,10100)(11,100,10010)
The Classes P and NP
Problems Solvable in Polynomial Time (An Example Kruskal’
Algorithm)
1. One tape can be used to store the nodes and their current
component numbers The length of this table is O(n).
2. A tape can be used,as we scan the edges on the input tape, to
hold the currently least edge weight found, among those edges
that have not been marked “used”. Scanning for the lowest
weight, unmarked edge takes O(n) time.
The Classes P and NP
Problems Solvable in Polynomial Time (An Example Kruskal’
Algorithm)
3. When an edge is selected in a round, This task takes O(n) time.
4. A tape can be used to hold the two components, i and j being
merged when an edge is found to connect two previously
unconnected components. This scan also takes O(n) time
The Classes P and NP
An NP Example The Traveling Salesman Problem