lecture 4: unsolvable problems
DESCRIPTION
Lecture 4: Unsolvable Problems. 虞台文. 大同大學資工所 智慧型多媒體研究室. Content. Enumerable and Decidable Sets Algorithm Solvability Problem Reduction Diagonalization Method. Lecture 4: Unsolvable Problems. Enumerable and Decidable Sets. 大同大學資工所 智慧型多媒體研究室. Set Enumerability and Generability. - PowerPoint PPT PresentationTRANSCRIPT
Lecture 4: Unsolvable Problems
虞台文大同大學資工所智慧型多媒體研究室
Content
Enumerable and Decidable SetsAlgorithm SolvabilityProblem ReductionDiagonalization Method
Lecture 4: Unsolvable Problems
Enumerable and Decidable Sets
大同大學資工所智慧型多媒體研究室
Set Enumerability and Generability
A * is enumerable (generable) if
computable function g: N* such that
( )g N AIf g is not totally defined, then D(g)={0, 1, …, k 1}.
The Generation Process(cf )gg N A
*A Enumerable (Generable)
(0)g A(1)g A(2)g A(3)g A
A:g N =
=
=
= Generate
The Enumeration Process(cf )gg N A
*A Enumerable (Generable)
(0)g A(1)g A(2)g A
A:g N =
=
=
A ?EnumerateEnumerate
The Enumeration Process(cf )gg N A
*A Enumerable (Generable)
(0)g A(1)g A(2)g A
A:g N =
=
=
A ?EnumerateEnumerate
Is such a process always
terminable?Is such a process always
terminable?
The Enumeration Process(cf )gg N A
*A Enumerable (Generable)
(0)g A(1)g A(2)g A
A:g N =
=
=
A ?EnumerateEnumerate
The Labeling Process(cf )gg N A
*A Enumerable (Generable)
(0)g A(1)g A(2)g A
A:g N =
=
=
LabelingLabeling
( )g ?
2
Exercises
1. Write two algorithms to enumerate (generate) the set of all even numbers of integer in different sequences.
2. What is difference between ‘countable’ (studied in discrete math) and `enumerable’?
The Countability of Real Number
Is R countable?
Is (0,1)R countable?
Prove (0,1)R is uncountable
Assume that (0, 1) is countable.
Suppose that it is counted as:
f0
f1
f2
f3
f4
d01 d02 d03 d04d00
d11 d12 d13 d14d10
d21 d22 d23 d24d20
d31 d32 d33 d34d30
d41 d42 d43 d44d40
0.
0.
0.
0.
0.
0 1 2 3 4
……………
… … … … … … ……
…{0,1, ,9}ijd
Prove (0,1)R is uncountable
Assume that (0, 1) is countable.
Suppose that it is counted as:
d00
d11
d22
d33
d44
…
f0
f1
f2
f3
f4
d01 d02 d03 d04
d12 d13 d14d10
d21 d23 d24d20
d31 d32 d34d30
d41 d42 d43d40
0.
0.
0.
0.
0.
0 1 2 3 4
……………
… … … … … ……
…{0,1, ,9}ijd
Consider the following number:
0 1 2 3 40. (0,1)v h h h h h
9 {0,1, ,9}i iih d
Prove (0,1)R is uncountable
Assume that (0, 1) is countable.
Suppose that it is counted as:
d00
d11
d22
d33
d44
…
f0
f1
f2
f3
f4
d01 d02 d03 d04
d12 d13 d14d10
d21 d23 d24d20
d31 d32 d34d30
d41 d42 d43d40
0.
0.
0.
0.
0.
0 1 2 3 4
……………
… … … … … ……
…{0,1, ,9}ijd
Consider the following number:
0 1 2 3 40. (0,1)v h h h h h
9 {0,1, ,9}i iih d
… … … … … ……
v=fk0. h0 h1 h2 h3 h4
…
Prove (0,1)R is uncountable
Assume that (0, 1) is countable.
Suppose that it is counted as:
d00
d11
d22
d33
d44
…
f0
f1
f2
f3
f4
d01 d02 d03 d04
d12 d13 d14d10
d21 d23 d24d20
d31 d32 d34d30
d41 d42 d43d40
0.
0.
0.
0.
0.
0 1 2 3 4
……………
… … … … … ……
…{0,1, ,9}ijd
Consider the following number:
0 1 2 3 40. (0,1)v h h h h h
9 {0,1, ,9}i iih d
… … … … … ……
v=fk0. h0 h1 h2 h3 h4
…
0 1 20.k k k k kkv f d d d d
kk kd h 9 kkd
4.5kkd
Prove (0,1)R is uncountable
Assume that (0, 1) is countable.
Suppose that it is counted as:
d00
d11
d22
d33
d44
…
f0
f1
f2
f3
f4
d01 d02 d03 d04
d12 d13 d14d10
d21 d23 d24d20
d31 d32 d34d30
d41 d42 d43d40
0.
0.
0.
0.
0.
0 1 2 3 4
……………
… … … … … ……
…{0,1, ,9}ijd
Consider the following number:
0 1 2 3 40. (0,1)v h h h h h
9 {0,1, ,9}i iih d
… … … … … ……
v=fk0. h0 h1 h2 h3 h4
…
0 1 20.k k k k kkv f d d d d
kk kd h 9 kkd
4.5kkd
Semidecidability
A * is semidecidable if there exists an algorithm which, when applying to any A, can decide that is in A, i.e., there exists an membership algorithm for A.
A A ?
A ?
True
False orNever Halt
Theorem 1
A is enumerable iff A is semidecidable.Pf) “”
A is enumerable g: N* such that g(N)=A.
Hence, given any A, we generate strings
g(0)=0g(1)=1
. . . . . . . .
Then, we will finally reach g(k) = k = .This allows us to concludes that A.
Theorem 1
A is enumerable iff A is semidecidable.Pf) “”What do we know?
A is semidecidableThere exists an membership algorithm for A on TM such
that( ) iff TM true A
Thinking first.
How to prove? Find g such that ( )g N A
( ) iff TM true A We have
Want ( )g N A
( ) ?g k 0,1,2,k
Theorem 1
A is enumerable iff A is semidecidable.Pf) “”
( ) iff TM true A We have
Want ( )g N A
( ) ?g k 0,1,2,k
Preliminaries 1 2 3 4 5 6 7 8 9 10123456789
10
Numbering the followingblack cells
1 2 3 4 5 6 7 8 9 10123456789
10
Theorem 1
A is enumerable iff A is semidecidable.Pf) “”
( ) iff TM true A We have
Want ( )g N A
( ) ?g k 0,1,2,k
0
1
2 34
5
6
7
Preliminaries
Numbering the followingblack cells
= {0, 1}
* = {, 0, 1, 00, 01, 10, 11, 000, …} 0 1 2 3 4 5 6 7
Enumerable
Theorem 1
A is enumerable iff A is semidecidable.Pf) “”
( ) iff TM true A We have
Want ( )g N A
( ) ?g k 0,1,2,k
The algorithmto generate g(k):
Step 1. Set n = k + 1.
Step 2. List the first n strings 0 1 1, , , n
Step 3. Hand simulates n steps of on TM for each 0 1 1, , , n
Theorem 1
A is enumerable iff A is semidecidable.Pf) “”
( ) iff TM true A We have
Want ( )g N A
( ) ?g k 0,1,2,k
The algorithmto generate g(k):
Step 1. Set n = k + 1.
Step 2. List the first n strings 0 1 1, , , n
Step 3. Hand simulates n steps of on TM for each 0 1 1, , , n
0 1 2 3 4 5 6 7 8 9123456789
10
0
n St
eps
n1-
Terminating Record
Theorem 1
A is enumerable iff A is semidecidable.Pf) “”
( ) iff TM true A We have
Want ( )g N A
( ) ?g k 0,1,2,k
The algorithmto generate g(k):
Step 1. Set n = k + 1.
Step 2. List the first n strings 0 1 1, , , n
Step 3. Hand simulates n steps of on TM for each 0 1 1, , , n
0 1 2 3 4 5 6 7 8 9123456789
10
0
n St
eps
n1-
Step 4. Let m= #terminating computations.Step 5. if m < k + 1
n= n + 1; goto Step 2;else return the kth string.
k
Theorem 2
A is enumerable iff A is a domain of some computable functions.
Pf)
Exercise
Theorem 2
A is enumerable iff A is a domain of some computable functions.
How about if A is not enumerable?
How about if A is not enumerable?
Discussion
Program Computability Enumeration
Enumeration Membership Determination
(Some reformation may be required)
(Semidecidability)
Complement Set
* \A A
*, A
Decidable Set
A * is decidable if there exists an computable function, say, D such that
if :
if
true AD
false A
Theorem 3
A is decidable iff and are enumerable.A A
A is decidable iff and are semidecidable.A A
Theorem 3
A is decidable iff and areA A enumerable.semidecidable.
Pf) “” Fact: * can be enumerated as 0, 1, 2, …
Since A is decidable, a computable function D st.
The computable function g to enumerate A can be:
if :
if
true AD
false A
D: 0 1 2 3 4 . . .
t f t t f . . .
g(0) g(1) g(2) . . .
A is enumerable.g:
Show that A is enumerable as follows:
Theorem 3
A is decidable iff and areA A enumerable.semidecidable.
Pf) “” Fact: * can be enumerated as 0, 1, 2, …
Since A is decidable, a computable function D st.
The computable function h to enumerate can be:
if :
if
true AD
false A
D: 0 1 2 3 4 . . .
t f t t f . . .h:
Show that is enumerable as follows:A
is enumerable.A
A
h(0) . . .h(1)
Theorem 3
A is decidable iff and areA A enumerable.semidecidable.
Pf) “”
Suppose 1 semidecides A, 2 semidecides .
For any *, input it to 1 and 2 simultaneously.
If 1 terminates, return true.
If 2 terminates, return false.
A
Lecture 4: Unsolvable Problems
Algorithm Solvability
大同大學資工所智慧型多媒體研究室
Enumeration, Decidability and Solvability
Enumeration:
Decidability:
Solvability:
*N
* ,true false
(Semidecidability)
To deal with the existence of algorithm (program) to solve problems.
That is, given a problem, whether there exists a program to solve (any instance of) the problem.
1
2
Example
Problem (PE: Program Equivalence):q = “Are program 1 and program 2 equivalent?”
,true falseAny
Algorithm?
PE
Example
Problem (PE: Program Equivalence):q = “Are program 1 and program 2 equivalent?”
Solvable? Computable?
1
2
:
:
string to represent 1
string to represent 2
1 2 1 2| and are e$ quivalent A
Decidable?
PE
Example
Problem (PE: Program Equivalence):q = “Are program 1 and program 2 equivalent?”
Problem Reformulation
Solvable? Computable?
1
2
:
:
string to represent 1
string to represent 2
1 2 1 2| and are e$ quivalent A
Decidable?
Problem PE is solvable iff A is decidable (recursive).Problem PE is solvable iff A is decidable (recursive).
PE
Definitions
Semisolvable:
Solvable:
Totally Unsolvable:
algorithm if q is true, it answers ‘yes’.if q is false, it may not give answer (never halt).
:P a true/ f alse problemq P
algorithm if q is true, it answers ‘yes’.if q is false, it answers ‘no’.
not semisolvale.
Problem and Complement ProblemP P
Is true?qP
Is not true?P q
Problem and Complement ProblemP P
1 2
Is tru ?, , eTM k TM kPE
Example:
1 2
Is not tru, , e?TM k TM kPE
Turing Machine Version
Problem and Complement ProblemP P
( )Is tr) ue?(P x h xE g
Example:
( ) ( )Is not true?PE g x h x
Register Machine Version
Theorem 4
P is solvable iff and are semisolvable.P P
Is true?qP
Is not true?P q
Pf) “” P is solvable algorithm P such that
if q is true, it answers ‘yes’.if q is false, it answers ‘no’.To show that P is semisolvable,
we need to find a algorithm ’ such that
is true( )
is false
true qq
q
?
Theorem 4
P is solvable iff and are semisolvable.P P
Is true?qP
Is not true?P q
Pf) “” P is solvable algorithm P such that
if q is true, it answers ‘yes’.if q is false, it answers ‘no’.To show that P is semisolvable,
we need to find a algorithm ’ such that
START
P
TRUEHALT
truefalse
’:
( ) if return true
(
)
else .Pq q
is true( )
is false
true qq
q
It can be
q
Theorem 4
P is solvable iff and are semisolvable.P P
Is true?qP
Is not true?P q
Pf) “” P is solvable algorithm P such that
if q is true, it answers ‘yes’.if q is false, it answers ‘no’.
START
P
TRUEHALT
falsetrue
”:
( ) if return true
no ( )
else .
t Pq q
not is true( )
is true
true qq
q
It can be
q
To show that is semisolvable, we need to find a algorithm ” such that
P
Theorem 4
P is solvable iff and are semisolvable.P P
Pf) “”
To run ’ and ” alternatively,
if ’ answers ‘yes’, then ‘yes’;
if ” answers ‘yes’, then ‘no’.
Corollary
P is solvable iff and are semisolvable.P P
P is semisolvable but not solvable
Pis totally unsolvable.
The Halting Problem
Register Machine Version
Turing Machine Version
: an -progra( ) ?
m" "
: memory configurationm
mHP
MM
: a -program
" ": memory configurati
,o, n
?HP kk
MTM
T
More simple,
" " : register functio( ? n)HP g x g
START
HALT
Theorem 5
The HP (halting problem) is not solvable.
: a -program
" ": memory configurati
,o, n
?HP kk
MTM
T
?
S1 S2 Sk1 Sk Sk+1 Sn1 Sn… … Blank TapeBlank Tape
Head
We will prove a simpler version.
We will prove a simpler version.會停嗎 ?
START
HALT
Theorem 5
The HP (halting problem) is not solvable.
: a -program
" ": memory configuratio
,n
1 ?,1
HP
TM
TM
S1 S2 Sk1 Sk Sk+1 Sn1 Sn… … Blank TapeBlank Tape
Head
?會停嗎 ?
Theorem 5
The HP (halting problem) is not solvable.
: a -program
" ": memory configuratio
,n
1 ?,1
HP
TM
TM
Pf) Assume that HP is solvable.
algorithm, given and <, 1>, can tell whether will halt on <, 1>.
Define @ ,1A TM
We can have an algorithm, say, decide to decide the elements of A.
( ) q
decide qq
true A
false A
That is,
Theorem 5
The HP (halting problem) is not solvable.
Pf)
@ ,1A TM
( ) q
decide qq
true A
false A
Construct strange
by making use of decide
START
Duplicate as @
HALT
decide
true falseWhat are done by strange?
What are done by strange?
Theorem 5
The HP (halting problem) is not solvable.
Pf)
@ ,1A TM
( ) q
decide qq
true A
false A
START
Duplicate as @
HALT
decide
true false
,1
,1@ ,1strange TM iff ,1 TM
Construct strange
by making use of decide
Theorem 5
The HP (halting problem) is not solvable.
Pf)
@ ,1A TM
( ) q
decide qq
true A
false A
START
Duplicate as @
HALT
decide
true false
,1
,1@ ,1strange TM iff ,1 TM
Construct strange
by making use of decide
The input to strange is a program’s string, say, .
strange will never halt on
if and only if
program will halt on feeding its code as input
parameter.
The input to strange is a program’s string, say, .
strange will never halt on
if and only if
program will halt on feeding its code as input
parameter.
Theorem 5
The HP (halting problem) is not solvable.
Pf)
@ ,1A TM
( ) q
decide qq
true A
false A
,1strange TM iff ,1 TM
,1strange strange TM iff ,1
strange strange TM
Assume that HP is solvable.. . . . . . . . . . . . . . . .
Theorem 5
The HP (halting problem) is not solvable.
Pf)
@ ,1A TM
( ) q
decide qq
true A
false A
,1strange TM iff ,1 TM
,1strange strange TM iff ,1
strange strange TM
Assume that HP is solvable.. . . . . . . . . . . . . . . .
START
Duplicate as @
HALT
decide
true false
,1strange
@ ,1strange strange
Theorem 6
The HP (halting problem) is not solvable.
The HP (halting problem) is semisolvable.
Pf)
Trivial(Run it)
The Non-Halting Problem (NHP)
Register Machine Version
Turing Machine Version
: an -progra( ) ?
m" "
: memory configurationm
mHP
MM
: a -program
" ": memory configurati
,o, n
?HP kk
MTM
T
NHP HP
Theorem 7
The NHP is not semisolvable.
The NHP is totally unsolvable.
Lecture 4: Unsolvable Problems
Problem Reduction
大同大學資工所智慧型多媒體研究室
Is a Problem Solvable?
Methods to identify the problems’ solvability:
Problem Reduction Diagonalization method Rice’s Theorem
P
Problem Reduction
Pq qr:
Let P and P’ be two problems. If there is an algorithm (r) which will map any qP into q’P st.
q is true iff q’ is true.
Then, we say that problem P reduces to P’.
P
Problem Reduction
Pq qr:
Let P and P’ be two problems. If there is an algorithm (r) which will map any qP into q’P st.
q is true iff q’ is true.
Then, we say that problem P reduces to P’.
Conceptually, P’ is larger.
P
Discussion
Pq qr:
q is true iff q’ is true.
If P’ issemisolvablesolvable How about P?
How about P?
P
Discussion
Pq qr:
q is true iff q’ is true.
If P’ issemisolvablesolvable P is
semisolvablesolvable
P
Discussion
Pq qr:
q is true iff q’ is true.
If P issemisolvablesolvable How about P’?
How about P’?
P
Discussion
Pq qr:
q is true iff q’ is true.
If P issemisolvablesolvable P’ is ?????????
P
Discussion
Pq qr:
q is true iff q’ is true.
If P’ isnot solvable
totallyunsolvable
How about P?How about P?
P
Discussion
Pq qr:
q is true iff q’ is true.
If P’ isnot solvable
totallyunsolvable
P is ????????
P
Discussion
Pq qr:
q is true iff q’ is true.
If P isnot solvable
totallyunsolvable
How about P’?How about P’?
P
Discussion
Pq qr:
q is true iff q’ is true.
If P isnot solvable
totallyunsolvable
P’ isnot solvable
totallyunsolvable
Discussion
PP
q qr:: an -program
" ": memory confi
(gura n
) ?tio
mm
HP
M MM
: a -program
" ": memory c
, ?, onfiguration
kk
HP
TM TMTM
HPM HPTM
HPTM HPM
Theorem 8
PP
q qr:: an -program
" ": memory confi
(gura n
) ?tio
mm
HP
M MM
: a -program
" ": memory c
, ?, onfiguration
kk
HP
TM TMTM
HPM HPTM
HPTM HPM
The halting-problems for TM(), R, SR, SR2,
… are semisolvable but not solvable.
The halting-problems for TM(), R, SR, SR2,
… are semisolvable but not solvable.
Theorem 9
The problem of TM equivalence (PE) is totally unsolvable.
" ?"PE TM TM
TM
TM ,true false
AnyAlgorithm?
Theorem 9
The problem of TM equivalence (PE) is totally unsolvable.
" ?"PE TM TM
Pf) Fact: NHP is totally unsolvable.
Method of problem reduction: Find r st.
: r NHP PE , ?k TM ? TM TM
true trueiff
How?
Theorem 9
The problem of TM equivalence (PE) is totally unsolvable.
Pf) Fact: NHP is totally unsolvable.
: r NHP PE , ?k TM ? TM TM
Input = <, k>?
START
HALT
true
false
?START
doesn’t halt on <k, 1>
Theorem 9
The problem of TM equivalence (PE) is totally unsolvable.
Pf) Fact: NHP is totally unsolvable.
: r NHP PE , ?k TM ? TM TM
Input = <, k>?
START
HALT
true
false
?START
doesn’t halt on <k, 1>
Lecture 4: Unsolvable Problems
Diagonalization Method
大同大學資工所智慧型多媒體研究室
Example Show that HP is not solvable using diagonalization method.
Fact: The set of all programs is enumerable. (why?) Let be the string representation of all
programs. Suppose that HP is solvable. Then, we can have the
following termination record: Construct strange such that:
0 1 2, , ,...
0
1
2
3...
001...
101...
000...
011...
0 0 1 1 …………. . .
0 1 2 3 …
1ji
0ji
,1 iff ,1strange j j j TM TM
Can you write such a
program?Can you write such a
program?
... ... ... ... ...k 1 0 1 0 …
…
Example Show that HP is not solvable using diagonalization method.
Fact: The set of all programs is enumerable. (why?) Let be the string representation of all
programs. Suppose that HP is solvable. Then, we can have the
following termination record: Construct strange such that:
0 1 2, , ,...
,1 iff ,1strange j j j TM TM
0
1
2
3...
001...
101...
000...
011...
0 0 1 1 …………. . .
0 1 2 3 …
... ... ... ... ...k 1 0 1 0 …
…
Example Show that HP is not solvable using diagonalization method.
Fact: The set of all programs is enumerable. (why?) Let be the string representation of all
programs. Suppose that HP is solvable. Then, we can have the
following termination record: Construct strange such that:
0 1 2, , ,...
,1 iff ,1strange j j j TM TM
0
1
2
3...
001...
101...
000...
011...
0 0 1 1 …………. . .
0 1 2 3 …
,1 iff ,1strange k k k TM TM
,1 iff ,1k k k k TM TM
Theorem 10
The total function problem is totally unsolvable.
Pf)
totally unsolvable not semisolvable
• Assume it is semisolvable.• Then, we can enumerate the all total function as:
0 1 2, , ,
• Let x1 be the input/output register.
• Then,0 0
1 1
1 2
:
:
:
f N N
f N N
f N N
Totally defined functions
Theorem 10
The total function problem is totally unsolvable.
Pf)
totally unsolvable not semisolvable
• Assume it is semisolvable.
0 0 0 0
1 1 1 1
2 2 2 2
3
0
1
3
2
33 3
(0)
(1)
0 1 2 3
(1) (2) (3)
(0) (2) (3)
( (2)
(3
0) (1) (3)
(0) (1) ) )(2
f f f f
f f f f
f
f
f
f f f
f
f
f f f f
. . . . . . . . . . . . . . . . . . . . .
• Define : ( ) 1ng n f n
• Clearly, g is total.
Theorem 10
The total function problem is totally unsolvable.
Pf)
totally unsolvable not semisolvable
• Assume it is semisolvable.
0 00
1
2
0 0
1 1 1 1
2 2 2 2
3 3 3 3 3
(0)
(1)
(2
0 1 2 3
(1) (2) (3)
(0) (2) (3)
(0) (1) (3)
(0) (1) (2)
)
(3)
(0) (1) (2) (3)i i i i i
f f f f
f f f f
f f f f
f f f f
f f f
f
f
f
f f
f
. . . . . . . . . . . . . . . . . . . . .
• Define : ( ) 1ng n f n
• Clearly, g is total.
g
Theorem 10
The total function problem is totally unsolvable.
Pf)
totally unsolvable not semisolvable
• Assume it is semisolvable.
0 00
1
2
0 0
1 1 1 1
2 2 2 2
3 3 3 3 3
(0)
(1)
(2
0 1 2 3
(1) (2) (3)
(0) (2) (3)
(0) (1) (3)
(0) (1) (2)
)
(3)
(0) (1) (2) (3)i i i i i
f f f f
f f f f
f f f f
f f f f
f f f
f
f
f
f f
f
. . . . . . . . . . . . . . . . . . . . .
• Define : ( ) 1ng n f n
• Clearly, g is total.
g
( ) ( )ig i f i ( ) 1if i
While programs
TotalFunctions
Theorem 11
There is a total function which is not the associate function of any count program.
Count programs
Exercises
1. Special halting problem (SHP) and general halting problem (GHP) are defined as follows:
Prove:a) If GHP is not solvable, then SHP is not solvable.b) If SHP is not solvable, then GHP is not solvable.
" ˆ ?"SHP TM
," ?"HP kG TM
Exercises
2. Special equivalence problem (SE) is defined as:
Show that SE is not solvable.
3. General equivalence problem (GE) is defined as:
Show that GE is not solvable.
" " : registe( ) 1 r fu ion? nctS ggE x
" " : register func) i( t? ong x yGE g
Exercises
4. Define
Show that MEMBER is not solvable.
: register function
" " : range of ? ff
f
MEMBER R f
z N
z R