Docsity

NP-Completeness - Algorithm and Complexity Analysis - Lecture Slides, Slides of Computer Science

Toggle sidebar
bg1
NP-Completeness
2
Properties of Algorithms
A given problem can be solved by many different algorithms. Which
ALGORITHMS will be useful in practice?
A working definition: (Jack Edmonds, 1962)
■Efficient: polynomial time for ALL inputs.
■Inefficient: "exponential time" for SOME inputs.
Robust definition has led to explosion of useful algorithms for wide
spectrum of problems.
■Notable exception: simplex algorithm.
3
Exponential Growth
Exponential growth dwarfs technological change.
■Suppose each electron in the universe had power of today’s
supercomputers.
■And each works for the life of the universe in an effort to solve TSP
problem using N! algorithm.
■Will not succeed for 1,000 city TSP!
1000! >> 101000 >> 1079 ×1013 ×109×1012
Quantity Number
Home PC instructions / second 109
Supercomputer instructions / second 1012
Seconds per year 109
Age of universe † 1013
Electrons in universe † 1079
Some Numbers
† Estimated
4
Properties of Problems
Which PROBLEMS will we be able to solve in practice?
■Those with efficient algorithms.
■How can I tell if I am trying to solve such a problem?
!Theory of NP-completeness helps.
Yes Probably No
Shortest path Longest path
Euler cycle Hamiltonian cycle
Min cut Max cut
2-SAT 3-SAT
Matching 3D-Matching
Unknown
Primality
Factoring
Graph isomorphism
Baseball elimination Soccer elimination
PLANAR-2-COLOR PLAN AR-3-COLOR
Bipartite vertex cover Vertex cover
PLANAR-4-COLOR PLAN AR-3-COLOR
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download NP-Completeness - Algorithm and Complexity Analysis - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

NP-Completeness

Properties of Algorithms

A given problem can be solved by many different algorithms. WhichALGORITHMS will be useful in practice?A working definition: (Jack Edmonds, 1962)^ n

Efficient: polynomial time for ALL inputs. n^

Inefficient: "exponential time" for SOME inputs. Robust definition has led to explosion of useful algorithms for widespectrum of problems.^ n

Notable exception: simplex algorithm.

3

Exponential Growth

Exponential growth dwarfs technological change.^ n

Suppose each electron in the universe had power of today’ssupercomputers. n^

And each works for the life of the universe in an effort to solve TSPproblem using N! algorithm. n^

Will not succeed for 1,000 city TSP!

1000

79

×

13

×
9 ×

12

Quantity

Number

Home PC instructions / second

9

Supercomputer instructions / second

12

Seconds per year

9

Age of universe †

13

Electrons in universe †

79

Some Numbers

† Estimated

Properties of Problems

Which PROBLEMS will we be able to solve in practice?^ n

Those with efficient algorithms. n^

How can I tell if I am trying to solve such a problem?

Theory of NP-completeness helps.Yes

Probably No

Shortest path

Longest path

Euler cycle

Hamiltonian cycle

Min cut

Max cut

2-SAT
3-SAT

Matching

3D-Matching

UnknownPrimalityFactoring

Graph isomorphism

Baseball elimination

Soccer elimination

PLANAR-2-COLOR
PLANAR-3-COLOR

Bipartite vertex cover

Vertex cover

PLANAR-4-COLOR
PLANAR-3-COLOR

Docsity.com

5

P

Decision problem X.^ n

X is a (possibly infinite) set of binary strings. n^

Instance: finite binary string s, of length |s|. n^

Algorithm A solves X if A(s) = YES

s

X.

Polynomial time.^ n

Algorithm A runs in polynomial-time if for every instance s, Aterminates in at most p(s) "steps", where p is some polynomial. Definition of P.^ n

Set of all decision problems solvable in polynomial time on adeterministic Turing machine. Examples:^ n

MULTIPLE: Is the integer y a multiple of x? n^

RELPRIME: Are the integers x and y relatively prime? n^

PERFECT-MATCHING: Given graph G, is there a perfect matching?

Strong Church-Turing Thesis

Definition of P fundamental because of SCT.Strong Church-Turing thesis:^ n

P is the set of decision problems solvable in polynomial time onREAL computers. Evidence supporting thesis:^ n

True for all physical computers. n^

Can create deterministic TM that efficiently simulates any realgeneral-purpose machine (and vice versa). Possible exception?^ n

Quantum computers: no conventional gates.

7

Efficient Certification

Certification algorithm.^ n

Design an algorithm that checks whether proposed solution is aYES instance. Algorithm C is an efficient certifier for X if:^ n

C is a polynomial-time algorithm that takes two inputs s and t. n^

There exists a polynomial p( ) so that for every string s, s

X

there exists a string t such that |t|

p(|s|) and C(s, t) = YES.

Intuition.^ n

Efficient certifier views things from "managerial" viewpoint. n^

It doesn’t determine whether s

X on its own.

n^

Rather, it evaluates a proposed proof t that s

X.

n^

Accepts if and only if given a "short" proof of this fact.

Certifiers and Certificates

COMPOSITE: Given integer s, is s composite?Observation. s is composite

there exists an integer 1 < t < ssuch that s is a multiple of t.^ n

YES instance: s = 437,669.^ –

certificate t = 541 or 809 (a factor)

Certifier:Is s a multiple of t?

NO

Input s:437,

Certificate t: 541

s is a YES instance

no conclusion

YES

Docsity.com

13

NP

Definition of EXP:^ n

Set of all decision problems solvable in exponential time on adeterministic Turing machine. Claim: NP

EXP.

Proof: Consider problem X

NP.

n^

Then, there exists efficient certifier C(s, t) for X. n^

To solve input s, run C(s, t) on all strings t with |t|

p(|s|).

n^

Return YES, if C(s, t) returns YES for any of these. Useful alternate definition of NP:^ n

Set of all decision problems solvable in polynomial time on aNONDETERMINISTIC Turing machine. n^

Intuition: act of searching for t is viewed as a non-deterministicsearch over the space of possible proofs. Nondeterministic TMcan try all possible solutions in parallel.

EXP

The Main Question

Does P = NP?

(Edmonds, 1962)

n^

Is the original DECISION problem as easy as CERTIFICATION? n^

Does nondeterminism help you solve problems faster? Most important open problem in computer science.^ n

If yes, staggering practical significance. n^

Clay Foundation Millennium $1 million prize.

NP

P If P

NP

If P = NP

EXP
P = NP

15

The Main Question

Generator (P)

Certifier (NP)

n^

Factor integer s.

n^

Is s a multiple of t?

n^

Color a map with minimum # colors.

n^

Check if all adjacent regionshave different colors.

n^

Design airfoil of minimum drag.

n^

Compute drag of airfoil.

n^

Prove a beautiful theorem.

n^

Understand its proof.

n^

Write a beautiful sonnet.

n^

Appreciate it.

n^

Devise a good joke.

n^

Laugh at it.

n^

Vinify fine wine.

n^

Be a wine snob.

n^

Orate a good lecture.

n^

Know when you’ve heard one.

n^

Ace an exam.

n^

Verify TA’s solutions.

Imagine the wealth of a society that produces optimal planes, bridges,rockets, theorems, art, music, wine, jokes.

The Main Question

Does P = NP?^ n

Is the original DECISION problem as easy as CERTIFICATION? If yes, then:^ n

Efficient algorithms for 3-COLOR, TSP, FACTOR,... n^

Cryptography is impossible (except for one-time pads) onconventional machines. n^

Modern banking system will collapse. n^

Harmonial bliss. If no, then:^ n

Can’t hope to write efficient algorithm for TSP. n^

But maybe efficient algorithm still exists for FACTOR....

Docsity.com

17

The Main Question

Does P = NP?^ n

Is the original DECISION problem as easy as CERTIFICATION? Probably no, since:^ n

Thousands of researchers have spent four frustrating decades insearch of polynomial algorithms for many fundamental NPproblems without success. n^

Consensus opinion: P

NP.

But maybe yes, since:^ n

No success in proving P

NP either.

Polynomial Transformation

Problem X polynomial reduces (Cook-Turing) to problem Y (X

P^

Y) if

arbitrary instances of problem X can be solved using:^ n

Polynomial number of standard computational steps, plus n^

Polynomial number of calls to oracle that solves problem Y. Problem X polynomial transforms (Karp) to problem Y if given anyinput x to X, we can construct an input y such that x is a YES instanceof X if and only if y is a YES instance of Y.^ n

We require |y| to be of size polynomial in |x|. Polynomial transformation is polynomial reduction with just one callto oracle for Y, exactly at the end of the algorithm for X.Note: all previous reductions were of this form!

19

NP-Complete

Definition of NP-complete:^ n

A problem Y in NP with the property that for every problem X in NP,X polynomial transforms to Y. n^

"Hardest computational problems" in NP. EXP

NP

P If P

NP

If P = NP

NP-

complete

EXP
P = NP

NP-Complete

Definition of NP-complete:^ n

A problem Y in NP with the property that for every problem X in NP,X polynomial transforms to Y. Significance.^ n

Efficient algorithm for any NP-complete problem

efficient algorithm for every other problem in NP. n^

Links together a huge and diverse number of fundamentalproblems:^ –

TSP, 3-COLOR, CNF-SAT, CLIQUE,.........

n^

Can implement any computer program in 3-COLOR. Notorious complexity class.^ n

Only exponential algorithms known for these problems. n^

Called "intractable" - unlikely that they can be solved given limitedcomputing resources.

Docsity.com

25

Minesweeper Consistency Problem

Minesweeper consistency problem.^ n

Given a state of what purports to be a Minesweeper games, is itlogically consistent.

YES NO

Minesweeper Consistency Problem

Minesweeper consistency problem.^ n

Given a state of what purports to be a Minesweeper games, is itlogically consistent. Claim. Minesweeper consistency is NP-complete.^ n

Proof idea: reduce from circuit satisfiability. n^

Build circuit by laying out appropriate minesweeperconfigurations.

A Minesweeper Wire

27

Minesweeper Consistency Problem

A NOT Gate

An AND Gate

A OR Gate

Minesweeper Consistency Problem

A 3-way Splitter A Phase Changer

Docsity.com

29

Minesweeper Consistency Problem

A Wire Crossing

Coping With NP-Completeness

Hope that worst case doesn’t occur.^ n

Complexity theory deals with worst case behavior. The instance(s)you want to solve may be "easy."^ –

TSP where all points are on a line or circle – 13,509 US city TSP problem solved

(Cook et. al., 1998)

31

Coping With NP-Completeness

Hope that worst case doesn’t occur.Change the problem.^ n

Develop a heuristic, and hope it produces a good solution. n^

Design an approximation algorithm:

algorithm that is guaranteed

to find a high-quality solution in polynomial time.^ –

active area of research, but not always possibleunless P = NP! – Euclidean TSP tour within 1% of optimal – stay tuned

Sanjeev Arora (1997)

Coping With NP-Completeness

Hope that worst case doesn’t occur.Change the problem.Exploit intractability.^ n

Cryptography.

Docsity.com

37

Co-NP Certifiers and Certificates

PRIME: Given integer s, is s prime?Observation. s is composite if andonly if there exists an integer 1 < t < ssuch that s is a multiple of t.^ n

NO instance: s = 437,669. Conclusions.^ n

PRIME

co-NP.

n^

COMPOSITE
P.

Certifier:Is s a multiple of t?

NO

Input s:437,

Certificate t: 541

s is a NO instance

no conclusion

YES

Co-NP Verifiers and Certificates

COMPOSITE: Given integer s, is s composite?Fact (Pratt). s is prime if and only ifs > 2 is odd and there exists aninteger 1 < t < s s.t.^ n

NO instance: 437,677. Conclusions.^ n

COMPOSITE

co-NP.

n^

PRIME
NP.

Certifier:17^(s-1) mod s = 1s - 1 = 2

×
×
×

17^(s-1)/2 mod s = 437,67617^(s-1)/3 mod s = 329,41517^(s-1)/36,473 mod s = 305,

NO

Input s:437,

Certificate t: 17

s is a NO instance

no conclusion

YES

of

divisors

prime

all

for

(mod

(mod

/) 1 ( 1

s-

p

s

t

s

t

p s s

− −

39

NP = co-NP?

Fundamental question: does NP = co-NP?^ n

Do YES-instances have short certificates if and only if NO-instances have short certificates. n^

Consensus opinion: no. Theorem. If NP

co-NP, then P

NP.

Proof. We prove if P = NP, then NP = co-NP.^ n

Key idea: P is closed under complementation, so if P = NP, thenNP is closed under complementation as well. n^

More formally, using the assumption P = NP: n^

Thus, NP

co-NP and co-NP

NP, so co-NP = NP.

NP
X
NP
X
P
X
P
X
NP
X^

co ∈ ⇒ ∈ ⇒ ∈ ⇒ ∈ ⇒ ∈

NP X

P X

P X

NP X

NP

X^

co

Good Characterizations

Good characterization: NP

s

co-NP.

n^

If problem X is in NP and co-NP, then:^ –

for YES instance, there is a short certificate – for NO instance, there is a short certificate n^

Provides conceptual leverage for reasoning about a problem. Examples.^ n

MAX-FLOW: given a network, is there an s-t flow of value

W.

-^ if yes, can exhibit s-t flow that achieves this value -^ if no, can exhibit s-t cut whose capacity is less than W n^

PERFECT-MATCHING: given a bipartite graph, is there a perfectmatching.^ –

if yes, can exhibit a perfect matching – if no, can exhibit a set of vertices S

L such that the total

number of neighbors of S is strictly less than |S|

Docsity.com

41

Good Characterizations

Observation. P

NP

s

co-NP.

n^

Proof of max-flow min-cut theorem and Hall’s theorem led tostronger results that max-flow and bipartite matching are in P. n^

Sometimes finding a good characterization seems easier thanfinding an efficient algorithm: linear programming. Fundamental question: does P = NP

s

co-NP?

n^

Mixed opinions. n^

Many examples where problem found to have a non-trivial goodcharacterization, but only years later discovered to be in P. n^

Note: PRIME

NP

s

co-NP, but not known to be in P.

A Note on Terminology

Knuth. (SIGACT News 6, January 1974, p. 12 – 18)Find an adjective x that sounds good in sentences like.^ n

FIND-TSP-TOUR is x. n^

It is x to decide whether a given graph has a Hamiltonian cycle. n^

It is unknown whether FACTOR is an x problem. Note: x does not necessarily imply that a problem is in NP or even adecision problem.Knuth's original suggestions.^ n

Hard. n^

Tough. n^

Herculean. n^

Formidable. n^

Arduous.

43

A Note on Terminology

Some English word write-ins.^ n

Impractical. n^

Bad. n^

Heavy. n^

Tricky. n^

Intricate. n^

Prodigious. n^

Difficult. n^

Intractable. n^

Costly. n^

Obdurate. n^

Obstinate. n^

Exorbitant. n^

Interminable.

A Note on Terminology

Hard-boiled. (Ken Steiglitz)^ n

In honor of Cook. Hard-ass. (Al Meyer)^ n

Hard as satisfiability. Sisyphean. (Bob Floyd)^ n

Problem of Sisyphus was time-consuming. n^

Hercules needed great strength. n^

Problem: Sisyphus never finished his task

unsolvable.

Ulyssean. (Don Knuth)^ n

Ulysses was note for his persistence and also finished.

Docsity.com