170 likes | 260 Views
algoritme in O(|I| qr ) time voor I in P: doe eerst A P /* geeft I' in SAT van size O(| | r ) doe dan A. alg. A O(| | q ). yes/no. P (I) SAT. A P O(| | r ). I P. probleem P 1 is reduceerbaar tot P 2 als afbeelding :P 1 P 2 zo dat:
E N D
algoritme in O(|I|qr) time voor I in P: doe eerst AP/* geeft I' in SAT van size O(| |r) doe dan A alg. A O(| |q) yes/no P(I)SAT AP O(| |r) IP probleem P1 is reduceerbaar tot P2 als afbeelding :P1 P2zo dat: I yes-instantie van P1 (I) yes-instantie van P2 als ook: polytime-algoritme, zeg A,met inputs IP1 en outputs (I)P2 dan P1 is 'polynomial‑reducable' tot P2 , notatie: P1 P2 TheoremCook (1971): SAT is -compleet, i.e.: each problemP of is polynomial reducable to SAT Corollary If SAT (or another -compleet problem) is solved by a polytime-algorithm A, then all problems P are polynomial solvable (=)Proof:
Observation 1 Given a problem P in If SAT (or more general a known -compleet problem) is polytime-transformable to P, then P is -compleet Observation 2 Given a problem P in If P is polytime-transformable to another polunomially-solvable problem Q in , then P also is in Next we use observation 1 for the problems P=CLIQUE and P=NODE-COVER. First we introduce these problems
YES for k=4 YES for k=3 CLIQUE Instance: graph G=(V, E) ; number k; Question: Is there a ‘clique’ subgraph HG with |V(H)|>=k NO for k=5
Satisfiability (formeel) Instance:2n booleans in sets B={b1, b2, ..., bn}en B={b1, b2, ..., bn}, [n-tal B={b1,..., bn} is vrij, n-tal B={b1, b2, ..., bn} is negatie dwz: vrij te kiezen: b1, ..., bn{true,false} en bt = NOT bt voor t=1,2..n] m ‘or-expressies’ C1, C2, ..., Cm met 1 of meer elementen in BB Question:Kan menb1 t/m bn zo kiezen ( truth-assignment)datelke 'clause' C1, C2, ..., Cmtrue wordt. (satisfying all the clauses) bv n=3, m=4 met C1=b1 or b3 or b2 ; C2=b2or b1; C3=b3 or b1; C4=b2 assignment b1=b2=b3=true mislukt; assignment b1=true; b2=b3=false mislukt; assignment b2=true, b1=b3=false satisfies all clauses
elke clause correspondeert met knopenregel, 1 knoop voor elke boolean • alle kanten bestaan behalve: • tussen knopen (booleans) van dezelfde clause • tussen booleans die elkaars negatie zijn Een probleem P zal -compleet zijn als: 1) P is in 2) voor een bekend -compleet P2 geldt: P2 P voorbeeld: Clique is -compleet 1) yes-certificaat is subset K met k knopen; O(n2) algoritme checkt kantexistentie 2) we tonen aan SAT CLIQUE : Zij B={b1,…,bn}; C1,C2, …,Cm, een SAT-instantie. bv: B={b1,b2,b3} en m=4 met C1=b1 or b3 or b2 ; C2=b2or b1; C3=b3 or b1; C4=b2
YES: V’ for k=5 YES: V’ for k=3 NODE-COVER Instance: graph G=(V, E) ; number k ; Question:can one cover E with a subset V’ of k or less nodes
G’s edges on upper-left node DEFINITION: The co-graphG=(V, co-E)of G=(V, E) has the same node set,but the complement set co-E as edge set: co-E ={(i,j): (i,j)E} Theorem: V’ is a node-cover of E(G) if and only if V\V’ forms a clique in G COROLLARY: CLIQUE NODE-COVER map I=<(V, E), k> of CLIQUE to (I)=<((V), (E)), (k)> of NODE-COVER, given as (V)=V , (E)=co-E and (k)=|V|-k
CLIQUE NODE-COVERmap I=<(V, E), k> of CLIQUE to (I) of NODECOVER, where (V,E)=(V,co-E) and (k)=|V|-k to proof:<(V, E), k> is yes instantie clique <(V,co-E),|V|-k> yes instantie node-cover proof:node set H forms a clique in (V,E) with |H|>=k/* i.e. H is yes-certificate for I iff( i, j H: (i,j) E ) and ( |H|>=k ) iff( i, j H: (i,j)Ïco-E) and ( |H|>=k ) ifffor each edge (i, j) of (V,co-E) node i is in V\H or node j is in V\Hand |V\H|<=|V|-k iff V\H is a node cover of (V, co-E) with |V\H|<=|V|-k/* i.e. V\H is yes-certificate for (I), (k)
SAT ILP (remember ILP: instance: (c,A,b) en k; question Is max {cx: Ax<=b, x Zn}>=k) SAT Instance: 2n booleans in sets B={b1, b2, ..., bn}en B={b1, b2, ..., bn}, m ‘or-expressies’ C1, C2, ..., Cm met 1 of meer elementen in BB vb n=3, m=4 met C1=b1 or b3 or b2 ; C2=b2or b1; C3=b3 or b1; C4=b2 Trafo: Introduceer een 0-1 variabele xb voor iedere b B en een voorwaarde en 0-1-variabele yi voor de tevredenheid van iedere clause We illustreren op het voorbeeld: Kies k=m max y1+…+ym x1+x3+(1-x2) >= y1 .. x2 >= y4 xj , yi {0,1}
YES: V’ for k=5 YES: V’ for k=3 NODE-COVER Instance: graph G=(V, E) ; number k ; Question:can one cover E with a subset V’ of k or less nodes
SAT(isfiability)Instance:2n booleans in sets B={b1, b2, ..., bn}en B={b1, b2, ..., bn}, vrij te kiezen: b1, ..., bn{true,false} en bt = NOT bt voor t=1,2..n]m ‘or-expressies’ C1, C2, ..., Cm met 1 of meer elementen van BB Question:Kan menb1 t/m bn zo kiezen ( truth-assignment)datelke 'clause' C1, C2, ..., Cmtrue wordt. (satisfying all the clauses) A special case of a problem restricts itself to instances of special type Special cases of -compleet problems may lie in 3-SAT restricts itself to instances of SAT where each clause <=3 booleans: 3-SAT Instance:2n booleans in sets B={b1, b2, ..., bn}en B={b1, b2, ..., bn}, vrij te kiezen: b1, ..., bn{true,false} en bt = NOT bt voor t=1,2..nm ‘or-expressies’ C1, ..., Cm elk met <=3 elementen vanBBQuestion:Kan menb1 t/m bn zo kiezen ( truth-assignment)datelke 'clause' C1, C2, ..., Cmtrue wordt. (satisfying all the clauses)
SET-COVER Instance:m sets S1, S2, ... Sm subsets of {1,2,.., n}; a number k (< m) [note: Each i=1,2..n lies in one or more of the subsets (i.e. S1,…Sm covers {1,2…n}) ] Question:Is there a subcover of {1,2,.., n} with k subsets or less NODE-cover SET-COVER: Basis set {1,…n} correspond to the edges e1 , en of (V,E) assume |E|=n subset Si defined for each i V is the set of numbers (edges) incident to i EXACT-COVER Instance:m sets S1, S2, ... Sm subsets of {1,2,.., n}; [note: Each i=1,2..n lies in one or more subsets (i.e. S1,…Sm covers {1,2…n}) ] Question:Is there a subcover of {1,2,.., n} with k<m subsets s.t. each i (=1,2…n) is in exactly one of these k subsets Weighted SET-COVER Instance:m subsets S1, ... Sm of {1,2,.., n} with weights w1, …wm; number k Question:Is there a subcover of total weight less than k HAMILTONIAN CYCLE (=special case of TSP with all edge weights 1) Instance: graph G=(V, E) with n nodes; Question: Is there H E with (|H|=n) edges as a tour visiting every node exactly once
MAX-CUT Instance:network (N, E) with edge weights cij >= 0; number k; Question:Is there a cutset [S, N\S] with capacity PARTITIONING Instance:indexedset of numbers {w1,w2,.., wn} Question:can one partition the index set {1..n}=I J such that: SUBSET SUM Instance:indexedset of numbers {w1,w2,.., wn} ; number k Question: Is there a subset of indices I such that GRAPH COLORING Instance: graph G=(V, E) ; number k; Question:Can we give each node i a color c(i) {1,2..k} s.t. c(i)<>c(j) if (i,j) E (i and j have different colors when they are connected by an edge)
2Dimensional Matching (2DM) Instance:set V={1,2,…,n}; P VxV a set (of more than n) pairs Question:Is there a subset P'={(x1,y1), … (xn,yn)} in P with {x1,..,xn}=V and {y1,..,yn}=V 3Dimensional Matching (3DM) Instance:set V={1,…n}; T VxVxV a set of triplets Question:Is there a subset T ’ = {(x1,y1, ,z1,), … (xn,yn,zn,)} of T with with {x1,..,xn}=V and {y1,..,yn}=V and {z1,..,zn}=V Alternative definition: 2Dimensional Matching (2DM) (and analogously fo 3DM) Instance:two different sets X={x1,..,xn} and Y ={y1,..,yn} both with n elements; P XxY a set of pairs (x,y) Question:Is there a subset P'={(xi1,yj1), … (xin,yjn)} of P with {xi1 ,.., xin}=X and {yj1 , .., yjn}=Y (i.e., all x- and y-coordinates in P' are different) Application (2DM) X={x1,..,xn} a set of gentlemenand Y ={y1,..,yn} a set of ladies; P XxY a set of matching pairs (x,y) that like each other enough (to get married) One can marry off all persons, make n (legally) married couples if and only if there is a subset P'={(xi1,yj1), … (xin,yjn)} of P with {xi1 ,.., xin}=X and {yj1 , .., yjn}=Y (i.e., no xi nor yi is married off twice)
SAT(isfiability) 3-SAT clique ILP graph coloring node cover 2-DM Ham-Cycle (&TSP) exact cover set cover subset sum min-cost flow weighted set cover partitioning Max-cut 3-DM knapsack Steiner problem problemen en mogelijke trafo's die NP-completeness aantonen (of case: 2DM of juist niet) pijl dik zwart: op college bewezen; pijl dun zwart: zie R. KARP '72; pijl rood: zelf bewijzen als serie 7A uitwerking inleveren van minstens 2 van de vier