is solving harder than checking?

22
Is solving harder than checking? Oded Goldreich Weizmann Institute of Science

Upload: nomlanga-tate

Post on 02-Jan-2016

42 views

Category:

Documents


3 download

DESCRIPTION

Is solving harder than checking?. Oded Goldreich Weizmann Institute of Science. Intuition about Solving Problems. Example 1: Sudoku. Intuition about Solving Problems. Example 2: Labyrinth (maze). Intuition about Solving Problems. Example 3: Jigsaw puzzle. Math Problems. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Is solving harder than checking?

Is solving harder than checking?

Oded GoldreichWeizmann Institute of Science

Page 2: Is solving harder than checking?

Intuition about Solving Problems

Example 1: Sudoku

Page 3: Is solving harder than checking?

Intuition about Solving Problems

Example 2: Labyrinth (maze)

Page 4: Is solving harder than checking?

Intuition about Solving Problems

Example 3: Jigsaw puzzle

Page 5: Is solving harder than checking?

Math Problems

Example 1: Factoring integers

= 787 811

= 6917 8893

638257

61512881

= 67 835561

Page 6: Is solving harder than checking?

Math Problems

Example 2: Solving a system of linear (or quadratic) equations

2x + 3y z = 9

x y + 3z = 4

3x + 2y + z = 0

x = 1

y = 2

z = 1

2x2 + 3xy z = 0

x y2 + 3yz = 5

3x + 2xy +2xz = 3

x = 1

y = 1

z = 1

Page 7: Is solving harder than checking?

Math Problems

Example 3: Coloring a Map (with 3 colors)

Page 8: Is solving harder than checking?

Math Problems

Example 4: Traveling Salesperson Problem (TSP)Given the pair-wise distances between 12 cities and a total distance bound, find a tour that visits all 12 cities and covers a total distance that does not exceed the bound.

Example 5: Knapsack

Given a sequence of 20 integers and a target T, find a subset of the integers that sums-up to T.

LocationJerusalem

Tel-Aviv

Haifa Tiberi

as Beer

Sheba Eilat

Jerusalem -- 58 151 152 81 309

Tel-Aviv 58 -- 95 134 105 346

Haifa 151 95 -- 69 197 438

Tiberias 152 134 69 -- 233 405

Beer Sheba 81 105 197 233 -- 241

Eilat 309 346 438 405 241 --

Page 9: Is solving harder than checking?

A common feature: Easy to check correctness

The fact that it is easy to check correctness of candidate solutions yields an obvious (but slow) way of finding solutions to all problems, called exhaustive search: Just try all potential solutions and check the correctness of each of them, halting with a correct solution once it is found.

Page 10: Is solving harder than checking?

Exhaustive search: an obvious (but slow) way of finding solutions to all problems

Example 3: 3-coloring a map (with 20 countries). 320

possibilities.

Trying all potential solutions, we find a correct one once it is tried.

Example 2: Labyrinth (with 20 junction/choices). 220

possibilities.

Example 1: Sudoku (with 50/81 entries missing). 950

possibilities.

Example 4: Factoring 8-digit integers. 10000 possibilities.

(When factoring 200-digit integers, there are 10100 possibilities!)

Example 5: TSP (with 12 cities). 11! = 39,916,800 possibilities.

Page 11: Is solving harder than checking?

Are there better ways to find solutions?

Example 3: 3-coloring a (3-colorable) map. (prob.) NO!

(That is, faster than by exhaustive search)

Example 1: Solving systems of linear equations.

YES!

Example 4: 2-coloring a (2-colorable) map. YES!

Example 5: TSP (traveling salesperson). (prob.) NO!

Example 2: Solving systems of quadratic equations.

(prob.) NO!

Example 6: Factoring integers. (prob.) NO.

Page 12: Is solving harder than checking?

Formulation: what do we mean by a search problem?

Example 3 (solving systems of equations): An instance is any system of (linear or quadratic) equations, and a solution is an assignment of numbers to the variables such that …

Example 2 (coloring maps): An instance is a 3-colorable map, and a valid solution is a 3-coloring of the areas such that no two adjacent areas are assigned the same color.

A problem is not a specific instance (e.g.,a specific Sudoko puzzle), but rather the general form/class/type (e.g., Sudoku).

A search problem consists of an infinite (or huge) set of instances and a concise/simple specification of valid solutions.Example 1 (Sudoku): An instance is any 9-by-9

rectangle partially filled with single digits, and a valid solution is an assignment of digits to the empty cells such that …

Page 13: Is solving harder than checking?

Formulation: search problems (more examples)

Example 6 (Knapsack): An instance is any sequence of numbers N1,N2,…,Nn,T, and a solution is a subset of the n first numbers that sums-up to T (i.e., a set I such that ∑iINi = T).

Example 5 (Factoring): An instance is a composite number N, and a valid solution is a pair of numbers (P,Q) such that N=PQ.

A search problem consists of an infinite (or huge) set of instances and a concise/simple specification of valid solutions.

Example 4 (TSP): An instance is any n-by-n matrix of distances among n cities and a bound L, and a valid solution is a tour that passes all n cities and has total length at most L.

Page 14: Is solving harder than checking?

The P-vs-NP Question (version 1: search problems)

“P” = All search problems that can be solved efficiently; that is, there exists an efficient procedure that, when given an instance of the problem, finds a valid solution to that instance (or indicates that none exists).

“NP” = All search problems for which valid solutions can be efficiently recognized; that is, there exists an efficient procedure that, when given an instance-solution pair, determines whether or not the solution is valid.

It is widely believed that there are problems in NP P.

For example: 3-Coloring, TSP, Knapsack, Solve-Quad-Equations,

and also Factoring.

Page 15: Is solving harder than checking?

Decision problems (a formulation)

A generic example (having solutions w.r.t a search problem): An instance is an instance of a search problem, and the question is whether this instance has a solution.

Example 2 (coloring maps): An instance is a map, and the question is whether it is 3-colrable (i.e., whether there exists a 3-coloring of the areas such that no two adjacent areas are assigned the same color).

Again, a problem is not a specific instance (e.g.,a specific Sudoko puzzle), but rather the general form/class/type (e.g., Sudoku).

A decision problem consists of an infinite (or huge) set of instances and a concise/simple specification of YES-instnaces (a set of instances having a “desired” property).

Example 1 (Sudoku): An instance is any 9-by-9 rectangle partially filled with single digits, and the question is whether it can be augmented such that …

Page 16: Is solving harder than checking?

Focus on the problem of 3-colorability

Coloring a Map with 3 colors such that no two adjacent areas are assigned the same color.

THM: Every map can be colored with four colors.

Some maps can be colored with three colors, this one not (e.g., Belarus is surrounded by five neighbors).

The decision problem: Given a map, determine whether it is 3-colorable.

Page 17: Is solving harder than checking?

The P-vs-NP Question (version 2: decision problems)

P = All decision problems that can be solved efficiently; that is, there exists an efficient procedure that, when given an instance of the problem, determines whether it is a YES-instance.

NP = All decision problems for which each YES-instance has an efficiently verifiable certificate; that is, there exists an efficient procedure that, when given an instance-certificate pair, determines whether or not the certificate is valid.

It is widely believed that there are problems in NP P.

For example: 3-Coloring, TSP, Knapsack, Solve-Quad-Equations.

Page 18: Is solving harder than checking?

Showing that an NP-problem is not in P

P = All decision problems that can be solved efficiently; that is, there exists an efficient procedure that, when given an instance of the problem, determines whether it is a YES-instance.

NP = All decision problems for which each YES-instance has an efficiently verifiable certificate; that is, there exists an efficient procedure that, when given an instance-certificate pair, determines whether or not the certificate is valid.

Assuming that PNP (but not knowing it for a fact), can we tell whether a specific problem is in NP-P?

We can only hope for a conditional result (i.e., cond’ed on PNP). We say that an NP-problem is NP-complete if the ability to efficiently solve it implies the ability to efficiently solve any problem in NP.

PNP NP-complete problems are hard to solve.

Thus, showing that a problem is NP-complete will do.

(For example: 3-Coloring, TSP, Knapsack, Solve-Quad-Equations.)

Page 19: Is solving harder than checking?

Universal problems (NP-completeness)

P = All decision problems that can be solved efficiently; that is, there exists an efficient procedure that, when given an instance of the problem, determines whether it is a YES-instance.

NP = All decision problems for which each YES-instance has an efficiently verifiable certificate; that is, there exists an efficient procedure that, when given an instance-certificate pair, determines whether or not the certificate is valid.

A problem in NP is called NP-complete if the ability to efficiently solve it implies the ability to efficiently solve any problem in NP.

Recall: PNP NP-complete problems are hard to solve.How can NP-complete problems possibly

exist? (Let alone how can we prove that they exist?)

Indeed, a good question to be answered next.

Still, let us state (as a fact/theorem) that 3-Coloring, TSP, Knapsack, Solve-Quad-Equations are all NP-complete.

Page 20: Is solving harder than checking?

Universal problems (NP-completeness) [continued]

A (decision) problem C in NP is called NP-complete if the ability to efficiently solve it implies the ability to efficiently solve any (decision) problem D in NP.

How can NP-complete problems possibly exist? (Let alone how can we prove that they exist?)

Idea: An efficient transformation of instances of

(any NP) problem D into instances of problem C such that YES-instances are mapped to YES-instances (and NO-instances are mapped to NO-instances).

For example: 3-Coloring, TSP, Knapsack, Solve-Quad-Equations are all NP-complete. Instances, say, of FACTORING (in NP) can be mapped to any of them.

Page 21: Is solving harder than checking?

Universal problems (NP-completeness) [2nd cont.]

A (decision) problem C in NP is called NP-complete if the ability to efficiently solve it implies the ability to efficiently solve any (decision) problem D in NP.

Shown via an efficient transformation of instances of (any NP) problem D into instances of problem C such that YES-instances are mapped to YES-instances (and NO-instances are mapped to NO-instances).

NONO

YESYESD

C

(e.g.,3Color)

(e.g.,Factor)

Page 22: Is solving harder than checking?

The EndThe slides of this talk are available at

http://www.wisdom.weizmann.ac.il/~oded/T/p-vs-np.pptA related textbook is available at http://www.wisdom.weizmann.ac.il/~oded/bc-book.html