cs211 problems: unsolvable, unfeasible and unsolved topic 3: p and np

19
CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

Upload: devin-silverthorn

Post on 31-Mar-2015

235 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

CS211

Problems: unsolvable, unfeasible and unsolved

Topic 3: P and NP

Page 2: CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

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 (not the same as uncomputable) problem in computer science This problem is still open

Page 3: CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

Better Machines vs. Better AlgorithmsNew machine.•Costs $$$ or more.•Makes "everything" finish sooner.•Incremental quantitative improvements (Moore's Law).•May not help much with some problems.New algorithm.•Costs $ or less.•Dramatic qualitative improvements possible! (million times faster)•May make the difference in allowing solution at all •May not help much with some problems.

Page 4: CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

P – a category of algorithmsRelatively Efficient: polynomial time for ALL inputs.- mergesort requires N logN steps

Inefficient: "exponential time" for SOME inputs.- brute force TSP takes N! steps (TSP coming up)

P is the set of all DECISION problems that are solvable in POLYNOMIAL TIME on a DETERMINISTIC Turing machine.(decision problems are problems reduced to yes/no)

(For instance, CAN you sort these numbers? YES or NO) (best thing to do is just sort them)

Page 5: CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

What is the story on non-polynomial time?

Page 6: CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

It takes how long????

Page 7: CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

Examples of P (lots of them)

MULTIPLE: Is the integer y a multiple of x?•YES: (x, y) = (17, 51).•NO: (x, y) = (17, 50).•O(1)

SORT: Can you sort these n numbers?•The answer is always yes – just do it•O(n logn)

Page 8: CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

Apparent Counter-ExamplesTravelling Sales Person (TSP): Given all the N state capitals, can you find a route through them that costs < some amount

would have to try all N! possibilities - O(N!)

Satisfiability (SAT): Is there a way to assign values to a boolean expression in N variables that makes it true?

P && Q is true when P is true and Q is true But you would have to try all combinations -

O(2N)

(but can we be sure there isn’t a better algorithm??)

Page 9: CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

NP – another category of algorithms

• NP: does NOT mean "not polynomial.“

• NP: set of all decision problems with polynomial CERTIFICATION (ie checking) algorithm.

Equivalent definition• NP: set of all decision problems solvable in polynomial time on a NONDETERMINISTIC (ie lucky) Turing machine.

Page 10: CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

Certifier: check whether a proposed "solution" is correct.– proposed solution is called CERTIFICATE

– certificate must be of polynomial size

Page 11: CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

Examples

• Consider the TSPIf I give you a path you can check in O(N) whether it costs less than $$$

• Consider SATIf I give you a solution you can check it - decide if the expression is true in O(N) again

Page 12: CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

Other definition uses non-determinism

• That means that at every stage TM can guess the best solution.

• So, TSP: pick a town (lucky), pick another etc – O(N)

• Sorting: go through the list place each element in the ‘right’ place – O(N)

• You can actually do this on a TM but have to simulate parallelism which is exponential

Page 13: CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

• Obviously P NP• Is P = NP? THIS IS UNSOLVED!• Unlikely but no one has every proved it• Huge prize available!

Page 14: CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

NP complete-ness

• A problem in NP with the property that if it can be solved efficiently, then it can be used as a subroutine to solve any other problem in NP efficiently.

• "Hardest computational problems" in NP.

If any NP complete

problem is in P - then they ALL are

Page 15: CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

Some problems are NP complete

• TSP• SAT

Page 16: CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

Some problems it is still unknown whether they are NP complete

See Integer factorizationhttp://en.wikipedia.org/wiki/Prime_factorization decomposition of an integer into its prime divisors

(for instance 24 is 2x2x2x3)When the numbers are very large, no efficient algorithm is

known. There is an obvious slow algorithm, just start dividing by the primes 2,3,5, etc.

An algorithm which efficiently factors any integer would render RSA-based public-key cryptography insecure (Rivest, Shamir and Adleman – MIT 1970s).

Page 17: CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

Some problems were thought to be NP and then turned out not to be

See Linear Programming

http://www.quora.com/What-problems-were-once-thought-not-to-be-solvable-in-polynomial-time-but-eventually-were

But they weren’t NP complete problems of course

Page 18: CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

Coping with P, NP, and NP completeness

• Make up a pretty good approximation algorithm• Assume the worst case doesn’t occur (you have to

work at it to make TSP where you just go to cheapest place next, not an OK algorithm)

• Keep trying to show P=NP

But don’t look like an idiot by not recognising them!Insert story here

Page 19: CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

So, what has been ‘the point’ of all this?•The general idea of a machine with states, transitions and an infinite tape•Explaining the idea that a Turing machine can compute anything that is computable - actual machines are irrelevant•The notion that there are things that aren't computable (halting problem is the obvious one)•The idea that some algorithms are fine in theory but not in practice•That there exist open problems in Computer Science

It’s all Mark Neal’s fault: I just don't want them to look stupid when the topic of computability comes up at a cocktail party •Insert story here ; )