1
Desiderata'. Suppose we could solve problem Y in polynomial-time.
NP APPROXIMATION What else could we solve in polynomial time?
Reduction. Problem X polynomial-time (Cook) reduces to problem Y if arbitrary
instances of problem X can be solved using:
・Polynomial number of standard computational steps, plus
・Polynomial number of calls to oracle that solves problem Y.
Lec 23 : NP- Approximation CLRS 34-35
computational model supplemented by special piece
(mostly Kevin Wayne slides) of hardware that solves instances of Y in a single step
Algorithm
instance I
solution S to I
for Y
(of X)
Algorithm for X
Decision problem.
3-SAT ・Problem X is a set of strings.
・Instance s is one string.
es
uc
red
VERTEX-COVER HAM-CYCLE PLANAR-3-COLOR SCHEDULING Ex.
・Problem PRIMES = { 2, 3, 5, 7, 11, 13, 17, 23, 29, 31, 37, …. }.
・Instance s = 592335744548702854681.
・AKS algorithm: solves PRIMES in O( | s | 8 ) steps.
SET-COVER TSP 3-SAT poly-time reduces to all of
these problems (and many, many more)
3 4
Definition of P NP
P. Decision problems for which there is a poly-time algorithm. Certification algorithm intuition.
・Certifier views things from "managerial" viewpoint.
・Certifier doesn't determine whether s ∈ X on its own;
Problem Description Algorithm yes no rather, it checks a proposed proof t that s ∈ X.
MULTIPLE Is x a multiple of y ? grade-school division 51, 17 51, 16 Def. Algorithm C(s, t) is a certifier for problem X if for every string s,
s ∈ X iff there exists a string t such that C(s, t) = yes.
REL-PRIME Are x and y relatively prime ? Euclid (300 BCE) 34, 39 34, 51
"certificate" or "witness"
PRIMES Is x prime ? AKS (2002) 53 51 Def. NP is the set of problems for which there exists a poly-time certifier.
・C(s, t) is a poly-time algorithm.
・Certificate t is of polynomial size:
Is the edit distance between x
EDIT-DISTANCE dynamic programming niether neither acgggt ttttta | t | ≤ p( | s | ) for some polynomial p(⋅).
and y less than 5 ?
Is there a vector x that Gauss-Edmonds
L-SOLVE satisfies Ax = b ?
elimination
Remark. NP stands for nondeterministic polynomial time.
Is an undirected graph
depth-first search
U-CONN G connected? (Theseus)
5 6
COMPOSITES. Given an integer s, is s composite? SAT. Given a CNF formula Φ, does it have a satisfying truth assignment?
3-SAT. SAT where each clause contains exactly 3 literals.
Certificate. A nontrivial factor t of s. Such a certificate exists iff s is composite.
Moreover | t | ≤ | s |. Certificate. An assignment of truth values to the Boolean variables.
Certifier. Check that 1 < t < s and that s is a multiple of t. Certifier. Check that each clause in Φ has at least one true literal.
instance s 437669
instance s
certificate t 541 or 809 437,669 = 541 × 809
certificate t x1 = true, x2 = true, x3 = false, x4 = false
Conclusion. COMPOSITES ∈ NP. in fact, COMPOSITES ∈ P
Conclusions. SAT ∈ NP, 3-SAT ∈ NP.
7 8
Certifiers and certificates: Hamilton path Definition of NP
HAM-PATH. Given an undirected graph G = (V, E), does there exist a simple path P NP. Decision problems for which there is a poly-time certifier/verifier
that visits every node?
Problem Description Algorithm yes no
Certificate. A permutation of the n nodes.
Is there a vector x
Gauss–Edmonds
L-SOLVE that satisfies Ax = b ?
Certifier. Check that the permutation contains each node in V exactly once, and that elimination
9 10
NP. Decision problems for which there is a poly-time certifier. P. Decision problems for which there is a poly-time algorithm.
NP. Decision problems for which there is a poly-time certifier.
EXP. Decision problems for which there is an exponential-time algorithm.
Claim. P ⊆ NP.
“ NP captures vast domains of computational, scientific, and mathematical
Pf. Consider any problem X ∈ P.
endeavors, and seems to roughly delimit what mathematicians and scientists
・By definition, there exists a poly-time algorithm A(s) that solves X.
have been aspiring to compute feasibly. ” — Christos Papadimitriou ・Certificate t = ε, certifier C(s, t) = A(s). ▪
Claim. NP ⊆ EXP.
Pf. Consider any problem X ∈ NP.
“ In an ideal world it would be renamed P vs VP. ” — Clyde Kruskal ・By definition, there exists a poly-time certifier C(s, t) for X,
where certificate t satisfies | t | ≤ p( | s | ) for some polynomial p(⋅).
・To solve input s, run C(s, t) on all strings t with | t | ≤ p(| s |).
・Return yes if C(s, t) returns yes for any of these potential certificates. ▪
Remark. Time-hierarchy theorem implies P ⊊ EXP.
11 12
The main question: P vs. NP The main question: P vs. NP
Q. How to solve an instance of 3-SAT with n variables? Does P = NP? [Cook 1971, Edmonds, Levin, Yablonski, Gödel]
A. Exhaustive search: try all 2n truth assignments. Is the decision problem as easy as the certification problem?
Q. Can we do anything substantially more clever?
Conjecture. No poly-time algorithm for 3-SAT.
EXP NP EXP
"intractable"
P P = NP
If P ≠ NP If P = NP
If yes. Efficient algorithms for 3-SAT, TSP, 3-COLOR, FACTOR, …
If no. No efficient algorithms possible for 3-SAT, TSP, 3-COLOR, …
Consensus opinion. Probably no.
13 14
P ≠ NP. P ≠ NP.
P ≠ NP. P = NP.
“ In my opinion this shouldn’t really be a hard problem; it’s just “ I think that in this respect I am on the loony fringe of the mathematical
that we came late to this theory, and haven’t yet developed any community: I think (not too strongly!) that P=NP and this will be
techniques for proving computations to be hard. Eventually, it will proved within twenty years. Some years ago, Charles Read and I
just be a footnote in the books. ” — John Conway worked on it quite bit, and we even had a celebratory dinner in a
good restaurant before we found an absolutely fatal mistake. ”
— Béla Bollobás (2002)
17 18
P = NP, but only Ω(n100) algorithm for 3-SAT. Millennium prize. $1 million for resolution of P = NP problem.
P ≠ NP, but with O(nlog*n) algorithm for 3-SAT.
P = NP is independent (of ZFC axiomatic set theory).
19 20
NP-complete 3-satisfiability is NP-complete
NP-complete. A problem Y ∈ NP with the property that for every
Theorem. 3-SAT ∈ NP-complete.
problem X ∈ NP, X ≤ p Y. Pf. Cook, 1971; Levin, 1973
Theorem. Suppose Y ∈ NP-complete. Then Y ∈ P iff P = NP.
Pf. ⇐ If P = NP, then Y ∈ P because Y ∈ NP.
Pf. ⇒ Suppose Y ∈ P.
・Consider any problem X ∈ NP. Since X ≤ p Y, we have X ∈ P.
・This implies NP ⊆ P.
・We already know P ⊆ NP. Thus P = NP. ▪
Fundamental question. Do there exist "natural" NP-complete problems?
21 22
Theorem. If X ∈ NP-complete, Y ∈ NP, and X ≤ p Y, then Y ∈ NP-complete. Mathematics. Given integer a1, …, an, compute
Pf. Consider any problem W ∈ NP. Then, both W ≤ p X and X ≤ p Y. Mechanical engineering. Structure of turbulence in sheared flows.
25 26
RSA sold
RSA algorithm for $2.1 billion or design a t-shirt
27 28
Coping with NP-completeness Vertex cover
Q. Suppose I need to solve an NP-complete problem. What should I do? Given a graph G = (V, E) and an integer k, is there a subset of vertices S ⊆ V such
A. Theory says you're unlikely to find poly-time algorithm. that | S | ≤ k, and for each edge (u, v) either u ∈ S or v ∈ S or both?
4 9
5 10
29 30
• S[j] is set true if there is any subset of the numbers that sums to j, false otherwise
– Correctness: The sums that can be reached using any subset of
(We are showing only the true ones above)
the first i+1 variables are (a) the sums that can be reached using
• S is shown for the numbers { 4, 5 } with target 14. By choosing various subsets of
any subset of the first i of the x values (i.e. the subset doesn’t
the numbers {4,5 } any of the sums marked by a ( black, upper-case) T can be
reached include the use of xi+1) and (b) the sums that can be reached by
• How would S change if a new number were added to the set, e.g. the set of
using xi+1 added to any of the sums that can be reached using only
numbers becomes {4,5,3}? a subset of the first i of the numbers
• The new set of reachable sums includes everything in the old set, plus any sum ( * and interpret any out of range subscripts as false)
that can be reached by adding the new number to any of the sums that could be Don’t really need n tables, but must be careful overwriting - go from
reached using the old set ( these new values are shown in lower-case blue) top end to small end to avoid confusion between old and new values
33
34
Analysis of Pseudo-polynomial
Algorithm for subset sum
– SUBSETSUM with n numbers x1, x2, ...,xn and target t
algorithm for subset sum
– Bit Vector: Tables of length t – So we have n tables to fill out, each of length t
– Want Ti [ j ] = 1 if there is a subset of first i numbers that – Simple bit operation and table lookup for each entry on a
Random Access Machine
sums to j
– O(nt ) - is this polynomial time ?
– for i = 0, for all 1≦ j ≦ t, T0[ j ] = 0
– Certainly the O(n) part is fine, but what about the t?
– for 1 ≦ i ≦ n, for all 1≦ j ≦ t T i+1 [ j ] = Ti [ j ] ⋁ Ti [ j - xi+1
– How does t compare to the size of the input?
]
– t itself takes O(log2 t) bits to record, so its value t is
– Correctness: The sums that can be reached using the actually exponential in the size of its representation
first i+1 values of x are the same as the sums that can
– Example: if t were an n-bit number, t could have a value
be reached using the first i values (i.e. they don’t use
around 2n so the algorithm running in time t is running in
xi+1) along with the sums that can be reached using xi+1
time exponential in size of the input n
plus sums that are reachable using the first i values of x
– This is called a pseudo-polynomial algorithm
35SUBSETSUM with n numbers x1, x2, ...,xn and target t 36
Lebih dari sekadar dokumen.
Temukan segala yang ditawarkan Scribd, termasuk buku dan buku audio dari penerbit-penerbit terkemuka.
Batalkan kapan saja.