cs211 problems: unsolvable, unfeasible and unsolved topic 2: halting problem
TRANSCRIPT
CS211
Problems: unsolvable, unfeasible and unsolved
Topic 2: Halting problem
3 topics
1. Turing machines – as a definition of computable
2. An uncomputable problem and
3. Problems that take so long they might as well be – which leads to an unsolved problem in computer science (still open)
Some history1920s Hilbert asked "Is mathematics decidable?"
"Did there exist a definitive method which could, in principle, be applied to any assertion, and which guaranteed to produce a correct decision as to whether that assertion was true or false“ We call this decidable – reduce anything to yes/no
Last time we looked at Turing machines inspired by this idea of a ‘definitive method’, today look at ‘decidable’
Church Turing thesis (1936)
• Everything algorithmically computable is computable by a Turing machine
• You can’t ‘prove’ this it is a definition really
• Evidence that it is reasonable is that there were several definitions running around of ‘computable’ and they all turned out to be equivalent
• Nowadays we can show that TMs and ‘real’ computers are equivalent (discuss in relation to unlimited memory and new advances)
So ….
Last time we got a definition of ‘computable’
(i.e. to have an algorithm on a TM to solve)and hence ‘decidable’
(ie computable with a yes/no answer)
Now, are there problems that are not decidable?
Is it possible, in principle, to write a program to solve any problem?
• BTW, Notice that you can write a TM to simulate any programming language– Sequence– Selection (check if 2 things are equal)– Loop– (in fact less powerful because infinite memory in TM)
• So, Is it possible, in principle, to write a TM program to solve any problem?
• Can you write a computer program to solve any problem?
First, what did I tell you to do over break?
• Draw a TM to – Copy a binary number– Multiply a binary number by 2– Add 1 to a binary number– subtract unary (called monus – 7monus3 is 4
but 3monus7 is 0)– Decide if one number is bigger than another
• BTW my notation is from a book by Denning, Dennis and Qualitz
Back to main thread ….
Last time we got a definition of ‘computable’
(i.e. to have an algorithm on a TM to solve)and hence ‘decidable’
(ie computable with a yes/no answer)
Now, are there problems that are not decidable?
Is it possible, in principle, to write a TM program to solve any problem?
The answer is that ….
• There are problems that can be stated but not decided
• Hence there are things that are not computable
…. To describe them though we need to think ‘paradoxically’
Paradoxes – Grelling’s
Divide all adjectives into two categories:
• autological: self-descriptive
• heterological: not self-descriptive
Autological: pentasyllabic, awkwardnessful, recherché
Heterological: bisyllabic, palindromic, edible
Now – what kind of adjective is ‘heterological’
• Suppose it is heterological
That means it does not describe itself – but it does!
• Suppose it is not-heterological
That means it is not not self descriptive, ie it is self descriptive – but it isn’t!
The halting problemgiven a program and an input,
will the program eventually halt on that input,or will it run forever?
while True: continue –does not halt
print "Hello World!" –halts very quickly
Here is an outline of the proof (based on http://www.cgl.uwaterloo.ca/~csk/halt/):
•Suppose, that given any program (p – expressing program as a TM) and any input (i) whether that program stops on that input is computable. (We will show a contradiction)•That means there is an algorithm for deciding whether p stops on i, so, if there is an algorithm, there is another TM q where
q(p, i) = 1 if p doesn’t stop on i and
0 if p does stop on i•We can code up any machine as some number ‘x’ uniquely. •Consider yet another turing machine r – almost like a backwards q, but it runs machines on codings of themselves
r(x) = inf. loop if q(x,x) =0 // easy to put in inf loop 0 if q(x,x) = 1
•What happens if I apply r to itself?
If r(r) = inf loop (so q =0)
would mean that q(r,r) =0, which means r stops on r – contradiction
If r(r) = 0 (stops so q =1)
would mean q(r,r) = 1, which means r doesn’t stop on r - contradiction
Hence the initial assumption (that you can decide whether any program running on any input stops is computable)
must be wrong!
And so whether that initial program p stops on input i is
NOT – computable.
q(p, i) = 1 if p doesn’t stop on i and 0 if p does stop on i
Breathe!
So what?
• Well it means that not all problems CAN be solved on a computer!
• We "assume" that any step-by-step reasoning will solve any technical or scientific problem.
• “No" says the halting problem.• Other non-computable problems are often shown by being reduced to the halting problem
Raises the possibility of unsolvable problems
• There are others that are more ‘practical’ but harder to show
• But even the HP has simple consequences
• Student wanted to do an educational piece of software to detect all infinite loops – I said probably ‘no’ WHY??
OK, so now problems which are not solvable in reasonable
amounts of timeYou’ve done O(?) with Richard right?
•264 is 5 years worth of instructions on a supercomputer•2128 is 600,000 times the age of the universe in nanoseconds
N 10 100 1000 10000 100000
log10 N 1 2 3 4 5
40N+3 403 4003 40003 400003 4000003
N2/1000 0.1 10 1000 100000 10000000
2N 32 ?? ???
Anyone need a lifeline?
What have we done?
• Looked at a non-computable problem
• Seen some of the consequences• Reviewed O(?) if necessary