1 / 30

INHERENT LIMITATIONS OF COMPUTER PROGRAMS

CSci 4011. INHERENT LIMITATIONS OF COMPUTER PROGRAMS. HARDEST PROBLEMS IN NP. Theorem: A language B is NP-complete if:. Definition: A language B is NP-complete if:. 1. B  NP. 2. Every A in NP is poly-time reducible to B (i.e. B is NP-hard). 2. A is NP-complete and A · P B.

trella
Download Presentation

INHERENT LIMITATIONS OF COMPUTER PROGRAMS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSci 4011 INHERENT LIMITATIONS OF COMPUTER PROGRAMS

  2. HARDEST PROBLEMS IN NP Theorem: A language B is NP-complete if: Definition: A language B is NP-complete if: 1. B  NP 2. Every A in NP is poly-time reducible to B (i.e. B is NP-hard) 2. A is NP-complete and A ·P B If B is NP-Complete and P  NP, then There is no fast algorithm for B.

  3. We will use 3SAT to prove other problems are NP-Complete or NP-Hard. Examples include 3SAT ≤PDSAT, NAESAT, 2CSP… 3SAT ≤PCLIQUE 3SAT ≤P0/1-ILP 3SAT ≤PHAMPATH 3SAT ≤P3COLOR 3SAT≤PGRADUATION 3SAT ≤PVERTEX-COVER

  4. 2SAT 2SAT = {  |  is in 2cnf and  is satisfiable} Theorem. 2SAT ∈ P! Idea: a 2SAT clause (x ∨ y) is equivalent to (¬x → y) and (¬y → x). If there is a chain (x → z1)∧(z1 → z2)∧…∧(zk → ¬x) and (¬x→y1)∧(y1→y2)∧…∧(yj→x) then: x ↔ ¬x e.g. (x∨x) ∧ (¬x∨y) ∧ (¬y∨¬x) If not, the formula is consistent, so satisfiable.

  5. (x₁∨x₂)∧(x₂∨x̅₃)∧(x̅₁∨x₃) x₁ x₂ x₃ ͞x₁ ͞x₂ ͞͞x₃ def is_satisfiable_2cnf(F): V = Ø, E = Ø, G = (V,E) for l ∈ literals(F): V = V∪{l, ¬l} for (x∨y) ∈ clauses(F): E = E∪{(¬x,y), (¬y,x)} for x ∈vars(F): if has_path(G,x,¬x) and has_path(G,¬x,x): return False return True

  6. REDUCTION STRATEGIES A reduction by restriction shows that the source problem is a special case of the target problem. For example, 3SAT ≤P CNF-SAT because every satisfiable 3CNF is also a satisfiable CNF. Example. Prove 3SAT ≤P 4SAT by restriction. A 3CNF can be converted to an equivalent 4CNF by repeating one literal in each clause.

  7. c e e b b b b a a a a d d d d c c COLORING COLOR = { 〈G,k〉 | G is k-colorable } 3COLOR = { 〈G〉 | G is 3-colorable} Prove that 3COLOR ≤P COLOR

  8. e f b a g d i c h HAMILTONIAN PATHS HAMPATH = {〈G,s,t〉 | G has a hamiltonian path from s to t }

  9. Let LPATH = { 〈G,s,t,k〉 | G has a simple path from s to t of length at least k } Prove that HAMPATH ≤P LPATH Let HAMILTONIAN = { 〈G〉 | ∃s,t such that G has a hamiltonian path from s to t } Prove that HAMPATH ≤P HAMILTONIAN Let HAMCYCLE = { 〈G〉 | G has a simple directed cycle of length n} Prove that HAMPATH ≤PHAMCYCLE.

  10. e e b b a a d d c c VERTEX COVER VERTEX-COVER = {〈G,k〉 | G has a vertex cover of size at most k }

  11. e e b b a a d d c c INDEPENDENT SET INDSET = { 〈G,k〉 | G has an independent set of size at least k } Prove that VERTEX-COVER ≤P INDSET.

  12. SUBSET SUM SUBSET-SUM = { 〈y1,…, yn,t〉 |∃S⊆{1,…,n}. Σj∈Syj=t } Which of the following are in SUBSET-SUM? 〈1,3,5,7, 10〉 YES 〈19,11,27,4, 13〉 NO 〈19,11,27,4, 61〉 YES

  13. {〈(w1,v1)…,(wn,vn),W, V〉| ∃S⊆{1…n} so that Σi∈Swi≤ W and Σi∈Svi ≥ V} KNAPSACK = 1lb, $20 ½ lb $15 3 lbs $2000 15 lbs $500 50 ×

  14. Theorem. SUBSET-SUM ≤P KNAPSACK Proof. A subset sum instance is a knapsack where the weights are equal to the values: Let ƒ(y1,…,yn,t) = 〈(y1,y1)…(yn,yn),t,t〉. Then ∃S. Σi∈Syi = t iff ∃S. Σi∈Syi ≥ t and Σi∈Syi ≤ t, so 〈y1…yn,t〉 ∈ SUBSET-SUM iffƒ(y1…yn,t)∈KNAPSACK

  15. SET-COVER = {〈S1,…,Sn,k〉 | ∀i,Si⊆U and∃i[1…k] so that Si[1]∪Si[2]∪…∪Si[k] = U } Which of the following are in SET-COVER? YES 〈{1}, {1,2}, {2}, {3}, 2〉 NO 〈{1,4}, {1,2}, {1,3}, {4}, 2〉 YES 〈{1}, {2}, {1,2}, 2〉 Theorem. VERTEX-COVER ≤P SET-COVER Proof. A vertex cover instance is just a set cover instance where every node is a set of edges.

  16. REDUCTION STRATEGIES A reduction from A to B by local replacement shows how to “translate” between “units” of A and “units” of B. Example. vertex cover “units” are vertices and edges; set cover “units” are elements and sets. Example. CIRCUIT-SAT units are gates, CNFSAT units are clauses, 3SAT units are 3-literal clauses.

  17. SATISFYING CONSTRAINTS A 2csp is a list of constraints on pairs of variables Each constraint C(x,y) is a list of values for (x,y). An assignment satisfies a constraint if (x,y)∈C(x,y). An assignment satisfies a 2csp if it satisfies all constraints. e.g. Scheduling a project; seating at a wedding… 2CSP = { C | C is a satisfiable 2csp } Theorem. 2CSP is NP-Complete.

  18. Theorem. 2CSP is NP-Complete. Proof. 1. 2CSP ∈ NP. Given an assignment to the variables we can check that all constraints are satisfied in linear time. 2. 3SAT ≤P 2CSP. Idea: the main difference is that a 2csp constraint should have only two variables. Add variables to the 2csp that represent pairs of variables in the 3cnf, and constraints to enforce consistency with the 3cnf variables.

  19. Map 3cnf ϕ with n variables and m clauses to a 2csp Cϕ with 2n+m variables and 3m+n constraints: for each variable x ∈ϕ: add (vx,v¬x) ∈ {(0,1),(1,0)} for each clause (x∨y∨z) ∈ϕ: add vxy∈ {00,01,10,11} add (vxy,vz) ≠ (00,0) add (vxy,vx) ∈ {(00,0), (01,0), (10,1), (11,1)} add (vxy,vy) ∈ {(00,0), (01,1), (10,0), (11,1)} Claim. Cϕ∈ 2CSP ⇔ϕ∈ 3SAT: Proof. A satisfying assignment to ϕ can be mapped to a satisfying assignment to Cϕby assigning each vx = x and each vxy = 2vx+vy because… An assignment to Cϕ maps to an assignment to ϕ by setting each x = vx, because…

  20. GRADUATION A transcript is a set of course numbers a student has taken A major consists of: Pairs: exactly one of which must be taken Lists: at least one course of which must be taken GRADUATION = {〈T,M〉 | a subset of T satisfies M} For example: T = {1901A, 1902B, 1902A, 2011, 4041A, 4061, 4211} M = [1901A,1901B], [1902A,1902B] (4011,4041A,4041B), (4211,4707), (4061)

  21. GRADUATION ∈NP: The subset is a proof that (T,M) ∈GRADUATION. 3SAT ≤PGRADUATION: T = {101, 102, 201, 202, 301, 302} (x1⋁ x2⋁ ¬x3) ∧ (¬x1 ⋁ x2 ⋁ x2) ∧ (¬x2⋁ x3⋁ x1) M = [101, 102], [201, 202], [301, 302] (101,201,302), (101,201,201), (101,202,301)

  22. GRADUATION ∈NP: The subset is a proof that (T,M) ∈GRADUATION. 3SAT ≤PGRADUATION: Let  = C1∧ C2∧ … ∧Cm have variables x1…xk For each xi: add classes i01 and i02 to T. add pair (i01,i02) to M. For each Cj, we add a triple to M: if xi is a literal in Cj, the triple includes i01. if ¬xiis a literal in Cj, the triple includes i02.

  23. UHAMPATH No HAM PATH Undirected HAM PATH B A B A C D C D E F E F UHAMPATH = {〈G,s,t〉 | G is an undirected graph with a Hamiltonian path from s to t}

  24. HAMPATH≤PUHAMPATH Amid Aout B A Ain C D E F

  25. HAMPATH ≤PUHAMPATH B A C D E F

  26. HAMPATH≤PUHAMPATH f(G,s,t) = (G’,s’,t’) where: For each node u  G: add nodes uin, uout, umid to G’. add edges {uin,umid} and {umid,uout} to G’ For each edge (u,v)G, add {uout,vin} to G’ s’ = sin, t’ = tout. If 〈G,s,t〉HAMPATH, then 〈G’,s’,t’〉UHAMPATH: (s,u,v,..,t) →(sin,smid,sout,uin,umid,uout,vin,vmid,vout,…tout)

  27. HAMPATH≤PUHAMPATH If 〈G’,s’,t’〉∈UHAMPATH, then 〈G,s,t〉∈HAMPATH: Let (sin=v1,v2,…,v3n=tout) be the undirected path. Claim: for all i≥0, there exists u  G so that: v3i+1=uin, v3i+2=umid, v3i+3=uout. If v2 smid, then no vi=smid. So v2=smid, v3=sout i=0: Induction: if v3i = u’out, then v3i+1=uin, so v3i+2=umid. The directed Hamiltonian path is (u1, u2, …, un)

  28. 3SAT P SUBSET-SUM We transform a 3-cnf formula  into 〈y1…yn, t〉:   3SAT  〈y1…yn,t〉  SUBSET-SUM The transformation can be done in time polynomial in the length of 

  29. Each variable and each clause result in two yi’s. Each yi will have a digit for each clause and variable. x2 x1 C3 C2 C1 x1 (x1⋁ x2⋁ x2) ∧ (¬x1⋁ x2⋁ x2) ∧ (x1 ⋁ ¬x2 ⋁ x2) x2 C3 C2 C1

  30. 3SAT P SUBSET-SUM Let  = C1∧C2∧… Cm have k variables x1…xk. We output y1 … y2k + 2m, each a k+m-digit number. for each 1 ≤ j ≤ k: for each 1 ≤ I ≤m: the ith digit of y2j-1 is 1 if xj∈Ci, else 0 the ithdigit of y2j is 1 if ¬xj∈ Ci, else 0. digit j+m of y2j, y2j-1 is 1. For each 1 ≤j ≤m: y2k+2j = y2k+2j-1 = 10j-1 Output t = 11..1133..3

More Related