Unformatted text preview: Chapter 4 Undecidability
In this chapter, we will review some of the well known undecidability results. The fundamental
undecidability result is the undecidability of the Halting Problem for Turing Machines (HPTM). Theorem 4 HPTM: There is no algorithm which when given an arbitrary Turing Machine M and an arbitrary input
string x, can determine whether M will halt on x. A proof that the halting problem for programs is undecidable: Fix a high-level programming language that manipulates strings. Consider only programs that
map strings onto strings. Assume that programs and inputs are over a nite alphabet V . Thus,
programs and inputs come from V . Notation If P is in V and P denotes a program, we write P ] to avoid ambiguity.
De nition 10 Halting Problem for Programs(HPP):
Given: A program P and input x.
Question: Is P ](x) de ned? In other words, will P halt on x?
Claim: HPP is undecidable.
Proof: Suppose HPP is decidable. Then there exists an algorithm A to decide given an arbitrary
program P and an arbitrary input x whether P ](x) is de ned (i.e. whether P will halt on x).
YES NO P,x : P halts on x : P does not halt on x A In particular, since P can be an input string, we have
41 c 42 O.H.Ibarra YES NO P : P halts on P : P does not halt on P A Modify A so that on input P , B simulates A and if P halts on P , computes P ](P ),
NO : P does not halt on P If A outputs NO and halts, then so does B . If A outputs YES, then B also outputs YES and then
computes P ](P ).
Now B is a program (also a string in V ) and therefore is a valid input. Consider the computation
of B when given input B :
NO Since B is an algorithm, B ](B ) is de ned (i.e. B halts on B ). Let the value of B ](B ) = in V .
But from the last gure above, when B is given input B , the output will be YES B ](B ) = YES ,
i.e., B ](B ) = YES B ](B ) = YES . So we have: B ](B ) =
B ](B ) = Y ES
Since B is a deterministic program this is absurd. It follows that B does not exist, and hence A
does not exist. 2
The above proof can be adopted for TM's. Hence, we get as a corollary, the undecidability of
the HPTM. 4.1 Post Correspondence Problem
Post Correspondence Problem, or PCP for short, is de ned as follows: c 43 O.H.Ibarra De nition 11 Post's Correspondence Problem
Given: An alphabet , two n-tuples of non-null strings over : )
xn ) x y 2 +
yn ) i i
Question: Does (X Y ) have a solution? I.e. do there exist k 1 and indices i1 i2
1 and n such that xi1 xi2 xik = yi1 yi2 yik ?
X = (x1 x2
Y = (y1 y2 ik between Consider for example, X = (101 11 100) and Y = (01 1 11001). Then, the sequence 2,3,2 is a
solution for these tuples. We will show that PCP is undecidable. The undecidability of PCP can
be used to prove that other problems are also undecidable. We give two examples.
1. Ambiguity of Context Free Grammars. De nition 12 A CFG, G, is ambiguous if there exists a string in the language generated by
G with at least two distinct derivations. Theorem 5 The ambiguity problem for CFGs is undecidable.
Proof: We show that if there exists an algorithm that can determine whether a given CFG is ambiguous then we can construct an algorithm to solve PCP.
Suppose such an algorithm exists, call it A. Now, given any instance of the PCP problem
(X Y ), X = (x1
xn) Y = (y1
yn ), we construct a CFG, G(X Y ) such that G(X Y ) is
ambiguous if and only if (X Y ) has a solution. G(X Y ) is de ned as follows: S ! AjB
A ! 10j AxR j10j #xR 1 j n
j ByR j10j #yR 1 j n
B ! 10 j
It is easy to see that G(X Y ) is ambiguous if and only if (X Y ) has a solution. Now if we give
G(X Y ) as input to the algorithm A, then (X Y ) has solution if and only if A says that G(X Y )
is ambiguous. Thus we can solve PCP using A. But we know that PCP is undecidable hence
it is not possible to have any such algorithm A which solves the ambiguity problem. 2
2. Mortality Problem for Matrices The Mortality problem is de ned as follows: De nition 13 Mortality Problem
Given: A set of n n integer matrices, M = fM1 M2 Mk g and (i j ) 1 i j n.
Mis equal to 0 for some i1 i2
Question: Is the (i j ) component of Mi1 Mi2
(possibly with repetition)? c 44 O.H.Ibarra We can show that the Mortality problem is undecidable by using the fact that PCP is undecidable. Assume that there exists an algorithm A, which solves the mortality problem.
Now, given any instance, (X Y ) of the PCP problem, we convert it to an instance M of the
Mortality problem such that M is mortal if and only if (X Y ) has a solution. Here is a sketch
of the proof.
Given 2 non-null strings u v, we create a matrix M (u v) which satis es the following two
(a) the (3,2) entry of M (u v) is 0 if and only if u = v and
(b) for all words, u1 u2 v1 v2 M (u1 u2 v1 v2 ) = M (u1 v1 ) M (u2 v2 ).
If such matrices exist, then given the two sets of strings for any instance of the PCP
problem, X = (x1
xn) Y = (y1
yn), we can construct the corresponding matrices,
M (x1 y1 )
M (xn yn). From the two properties above, we see that a solution to (X Y )
exists if and only if there is some product of the matrices with the (3 2) entry equal to zero.
I.e. if there is a product M (xi1 yi1 ) M (xik yik )]3 2 = 0 then from the above properties it must be the case that xi1 xik = yi1 yik and vice versa. The construction of the matrices is de ned as follows, where n = j j E (x) = njxj, for x 2 +
c(x) = i, where x is the ith word in the lexicographical ordering of the strings in Example: = f0 1 2g Then n = j j = 3
c(0) = 1 c(1) = 2 c(2) = 3 c(00) = 4 c(01) = 5 c(02) = 6
E (01) = 32 = 9, since j j = 3 and j01j = 2. Exercise: 1. c(xy) = c(x) E (y) + c(y)
2. E (xy) = E (x) E (y)
For a pair of strings (x y), de ne the matrix 2
E (x) E (y) ; E (x) 0 7
M (x y) = 6 0
c(x) c(y) ; c(x) 1 3. Show that M (x y) satis es the properties (a) and (b) above. 2:
+ . c 45 O.H.Ibarra De nition 14 Modi ed PCP (MPCP)
Given: X = (x1 xn ) Y = (y1 yn)
Question: Do there exist k 1 and indices i1 ik with i1 = 1 such that xi1 xik = yi1 yik ?
Claim: PCP decidable ) MPCP decidable (or, equivalently, MPCP undecidable ) PCP undecidable).
Proof: (Idea). We show how we can convert an instance (X Y ) of MPCP to an instance (X 0 Y 0 )
of PCP such that (X Y ) has a MPCP solution if and only if (X 0 Y 0 ) has a PCP solution. We
illustrate the conversion by an example:
Suppose X = (x1 x2 x3 ) Y = (y1 y2 y3 ) is an instance of MPCP, where x1 = 1
y1 = 111
x2 = 10111
y2 = 10
x3 = 10
y3 = 0
De ne an instance (X 0 Y 0 ) of PCP by X 0 = (x00 x01 x02 x03 x04 ) Y 0 = (y0 y1 y2 y3 y4 ), where
x00 = /1/
y0 = /1/1/1
0 = 1/
0 = /1/1/1
y1 c c c
0 = 1/0/1/1/1/
x2 c c c c c y2 = /1/0
0 = 1/0/
0 = /0
x3 c c
y4 = /$
Then (X Y ) has an MPCP solution if and only if (X 0 Y 0 ) has a PCP solution. Why?
Claim: MPCP (and hence PCP) is undecidable.
Proof: (Idea). We need to construct an algorithm which when given an arbitrary TM, M and an
arbitrary input x, generates an instance of MPCP, (XM x YM x ), such that M halts on x if and
only if (XM x YM x) has an MPCP solution.
For the proof, we use a variant of the TM we call expandable DLBA:
/ 6 can expand
(q /) = (p /
c ;1) a1 a2
2-way R/W head an $ - can expand
(q $) = (p $ +1) q0 Thus, the DLBA can insert space to both ends, by inserting a blank, . Assume that there is
exactly one halting state f , and the machine halts on c. c 46 O.H.Ibarra c
/ 6 $ - b b b q0 c
/ $ 6 f Assume without loss of generality (w.l.o.g.) that jxj 1. The tuples (X Y ) are constructed
in such a way that they simulate the computation of M on input /a1 an $. Assume that the
worktape alphabet of M (which contains the input alphabet) is ;, plus c and $. The strings in X
and Y will be over the alphabet ; f/ $g Q f# g
#q /a a an $#
for all A in ; f/ $ #g
If (q /) = (p / +1)
If (q /) = (p / ;1)
If (q $) = (p $ ;1)
for all A in ; f/g
If (q $) = (p $ +1)
If (q A) = (p B +1)
for all A, A = /, A = $
If (q A) = (p B ;1)
for all A, A = /, A = $
for all C in ; f/g
for all A, A = /, A = $
X 0 De nition 15 The short(n) Problem 12 Given a positive integer n, calculate and print short(n), where short(n) is de ned to be the length
of a shortest program without input statements that prints n and halts. c 47 O.H.Ibarra This problem is not solvable. Before giving a formal proof, let us try to convince ourselves of this
by trying (and failing) to nd an algorithm to compute short(n).
How would one try to compute short(n)?
Here is one way you might think of computing short(n).
1: i := 1 Enumerate and test all programs of length i
If one of these programs prints n and halts then
short(n) := i
i := i + 1
end This idea may at rst seem to be a good algorithm. Enumeration of such programs is possible.
However, testing these programs is a problem because some of these programs will not halt. Thus,
this idea is not an algorithm.
Proof: A proof that short(n) is not computable. This is a proof by contradiction. Suppose
short(n) is computable. Let A be the algorithm that computes it. We will use A to show the
existence of a program Qm for every positive integer (constant) m. The following in Qm .
1: y := 1
z := short(y) /* compute this string using A */
if z < m then
write(y) y := y + 1
goto 1 Clearly if A exists then Qm exits. Now note that length(Qm ) = c + length(m) where c is a constant
= c + d log m, where d is a constant
c d log m
so for some m0 large enough, length(Qm ) < m0 . However this leads to a contradiction as follows:
1. For any m, Qm halts and prints the smallest integer k such that the shortest program printing
k has length m. c O.H.Ibarra 48 2. For large enough m = m0 , length(Qm ) < m0 .
3. Qm0 halts and prints the smallest integet k s.t. the length of the shortest program printing
k m0 , BUT Qm0 prints k and the length of Qm0 < m0. This is a contradiction. 2 De nition 16 Shortest Program Problem Given a positive integer n construct a shortest program (without input statements) that prints n
and halts. This problem is unsolvable otherwise we can solve the above problem. De nition 17 Program Optimization Problem Given a program P , nd the shortest program P equivalent to P . This problem is unsolvable.
Proof: This is a proof by contradiction. Assume there exists a program optimization algorithm
O. Its input would be a program P and its output would be an optimized program P . Clearly
there is an algorithm A1 that takes as input a positive integer n and outputs a trivial algorithm
P that prints n. Now one can construct another algorithm A2 , that takes a positive integer n and
uses it as input to A1 then uses the output of A1 as input to O. The output of A2 is the output of
O. Thus the output of A2 is a shortest program to print n. This is a contradiction. 2 ...
View Full Document
This note was uploaded on 01/28/2012 for the course CS 220 taught by Professor Ibarra,o during the Winter '08 term at UCSB.
- Winter '08