28
Unsolvability and Infeasibility

Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Embed Size (px)

Citation preview

Page 1: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Unsolvability and Infeasibility

Page 2: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Computability (Solvable)

A problem is computable if it is possible to write a computer program to solve it.

Can all problems be computed? This question concerned

mathematicians even before digital computers were developed. They looked for an algorithm (a finite set of instructions to carry out a task).

Page 3: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Turing

Alan Turing developed the concept of a computing machine in the 1930s

A Turing machine, as his model became known, consists of a control unit with a read/write head that can read and write symbols on an infinite tape.

Page 4: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Church-Turing Thesis

Any function that can be computed can be computed by a simple Turing Machine. The Turing Machine is as powerful as any algorithm.

Cannot prove thesis

Page 5: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Is there an unsolvable problem? YES A proof that there is a problem for

which there is no algorithm is not I can’t come up with an algorithm.

Therefore there is no algorithm that solves the problem.

I can’t develop a program . Therefore there is no algorithm that solves the problem.

We need some background:

Page 6: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Paradox There is a small town with only one

barber. The barber shaves only those people

who do not shave themselves. All people are shaved. Who shaves the barber? If… Assuming that such a barber exists,

leads to a contradiction. Thus he can’t exist.

Page 7: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Loop

A loop is a set of instructions that is executed repeatedly.

x=010 times: add 1 to x What will be the value of x when

the loop ends?

Page 8: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Loop

x=5while x > 0 subtract 1 from x What will be the value of x when

the loop ends? How many times will the loop be

executed?

Page 9: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Loop

x=-5while x ≠ 0 add 1 to x What will be the value of x when

the loop ends? How many times will the loop be

executed?

Page 10: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Loop

x=0while x ≠ 0 add 1 to x What will be the value of x when

the loop ends? How many times will the loop be

executed?

Page 11: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Loop

x=5while x ≠ 0 add 1 to x What will be the value of x when

the loop ends? How many times will the loop be

executed?

Page 12: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Infinite loop

Executes “forever”

Page 13: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Halt?

Given the initial value of x, we can predict whether this loop will end or halt.

Given a clock, can you predict whether it will halt? How long will you have to watch it?

Given an arbitrary program, can we predict whether it will end.?

Can we write a program to do this?

Page 14: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

The Halting problem Given a program and an input to the

program, determine if the program will eventually stop with this input

Running the program is not a solution. Suppose we tried to run the program corresponding to the infinite loop to see if it ends. We would get tired of waiting for the answer, and stop the program. Thus we would still not have a prediction.

Page 15: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

The Halting problem

Theorem: The Halting Problem is not Computable.

The Halting Problem is important because it proves the existence of an uncomputable/unsolvable problem.

Page 16: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Proof of Theorem

See the diagram Recall that both programs and

data are stored in binary. There is no difference in the representation.

Assume there is an algorithm A that solves the Halting Problem.

Write a new program N as follows:

Page 17: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

N

Given a binary representation of program P

Use algorithm A to determine if P halts on input P

If A says HALTS, N goes into an infinite loop.

If A says LOOPS, then N says HALTS.

Page 18: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

N Imagine giving N to itself as data. If A says that N HALTS, then N LOOPS. If A says that N LOOPS, then N HALTS. We have a paradox. A cannot exist.

Our only assumption was that there is an algorithm A that solves the halting problem. It was wrong.

The Halting Problem is not computable. It is unsolvable/uncomputable.

Page 19: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Complexity

linear time –proportional to the size of the data

Recall Finding the maximum value in a list of

n elements by looking at each element in turn is linear.

Sequential search is linear

Page 20: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Complexity

logarithmic time --algorithms that successively cut the amount of data to be processed in half at each step are logarithmic Finding max by comparing pairs Finding a value in a list of n sorted

elements using the binary search algorithm

Page 21: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Complexity

exponential time Processing all subsets of a set Trying all moves in chess

factorial time Processing all permutations Traveling Salesperson Problem

Page 22: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Feasible A problem is feasible if it can be

solved in a reasonable amount of time.

Must consider all algorithms. If at least one is able to do it, the problem is feasible.

A function can be computable, but yet infeasible.

Page 23: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Growth

n n2 2n n!

5 25 32 120

10

100 1024 3628800

20

400 1048576

2432902008176640000

Page 24: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Sort a set of n elements (I) The selection sort algorithm

find the largest of the n elements. find the largest of the remaining n-1

elements. find the largest of the remaining n-2

elements. … the smallest element is remaining. Time: n+ n-1+ ...+ 2+ 1 = n(n+ 1)/2

units quadratic

Page 25: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Sort a set of n elements (II)

Exhaustive listing and search List all permutations (orderings) of

the data Pick the one that is sorted. Time: n(n-1)(n-2) ... (3)(2)(1) = n!

units factorial. Not very efficient!

Page 26: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Feasible

Sorting is feasible because there exists a reasonable algorithm. quadratic

Linear Search Binary Search. logarithmic Finding maximum. both linear and

logarithmic.

Page 27: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Infeasible

Playing chess by considering every possible move is not. exponential

Considering every possible seating arrangement for a large group is not. factorial

Checking all possible subsets of a set is not . exponential

Page 28: Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems

Feasibility

Logarithmic and linear algorithms are feasible

Exponential and factorial algorithms are infeasible.

An approximate solution may be adequate for an infeasible problem.