Presentation is loading. Please wait.

Presentation is loading. Please wait.

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.

Similar presentations


Presentation on theme: "INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011."— Presentation transcript:

1 INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

2 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) HARDEST PROBLEMS IN NP 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. Theorem: A language B is NP-complete if:

3 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.

4 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.

5 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)

6 GRADUATION NP: The subset is a proof that (T,M) GRADUATION. 3SAT P GRADUATION: (x 1 x 2 ¬x 3 ) (¬x 1 x 2 x 2 ) (¬x 2 x 3 x 1 ) T = {101, 102, 201, 202, 301, 302} M = [101, 102], [201, 202], [301, 302] (101,201,302), (101,201,201), (101,202,301)

7 GRADUATION NP: The subset is a proof that (T,M) GRADUATION. 3SAT P GRADUATION: Let = C 1 C 2 … C m have variables x 1 …x k For each x i : add classes i01 and i02 to T. add pair (i01,i02) to M. For each C j, we add a triple to M: if x i is a literal in C j, the triple includes i01. if ¬x i is a literal in C j, the triple includes i02.

8 UHAMPATH A B CD EF No HAM PATH A B CD EF Undirected HAM PATH UHAMPATH = { G,s,t | G is an undirected graph with a Hamiltonian path from s to t}

9 HAMPATH P UHAMPATH A B CD EF A in A mid A out

10 HAMPATH P UHAMPATH A B CD EF

11 HAMPATH · P UHAMPATH f(G,s,t) = (G,s,t) where: For each node u G: add nodes u in, u out, u mid to G. add edges {u in,u mid } and {u mid,u out } to G For each edge (u,v) G, add {u out,v in } to G s = s in, t = t out. If G,s,t HAMPATH, then G,s,t UHAMPATH: (s,u,v,..,t) ! (s in,s mid,s out,u in,u mid,u out,v in,v mid,v out,…t out )

12 HAMPATH · P UHAMPATH If G,s,t 2 UHAMPATH, then G,s,t 2 HAMPATH: Let (s in =v 1,v 2,…,v 3n =t out ) be the undirected path. i=0: Induction: if v 3i = u out, then v 3i+1 =u in, so v 3i+2 =u mid. Claim: for all i0, there exists u G so that: v 3i+1 =u in, v 3i+2 =u mid, v 3i+3 =u out. The directed Hamiltonian path is (u 1, u 2, …, u n ) If v 2 s mid, then no v i =s mid. So v 2 =s mid, v 3 =s out

13 3SAT P SUBSET-SUM We transform a 3-cnf formula into y 1 …y n, t : 3SAT y 1 …y n,t SUBSET-SUM The transformation can be done in time polynomial in the length of

14 (x 1 x 2 x 2 ) (¬x 1 x 2 x 2 ) (x 1 ¬x 2 x 2 ) Each variable and each clause result in two y is. Each y i will have a digit for each clause and variable. C1C1 C2C2 C3C3 y1y y2y y3y y4y y5y5 100 y6y6 100 y7y7 10 y8y8 10 y9y9 1 y 10 1 t11333 x1x1 x2x2 x1x1 x2x2 C1C1 C2C2 C3C3

15 REDUCTION STRATEGIES A reduction by component design constructs gadgets that simulate variables and clauses. In particular a reduction must provide: a gadget to force the solution to the target instance to choose either x or ¬x a gadget to force the solution to the target instance to choose one literal from each clause a gadget to force the solution to the target instance to satisfy every clause

16 K- CLIQUES b a e c d f g

17 3SAT P CLIQUE We transform a 3-cnf formula into G,k such that 3SAT G,k CLIQUE The transformation can be done in time polynomial in the length of

18 (x 1 x 1 x 2 ) ( x 1 x 2 x 2 ) ( x 1 x 2 x 2 ) x1x1 x 1 x1x1 x2x2 x 2 x2x2 x2x2 x 1 k = #clauses

19 (x 1 x 1 x 1 ) ( x 1 x 1 x 2 ) (x 2 x 2 x 2 ) ( x 2 x 2 x 1 ) x1x1 x1x1 x2x2 x2x2 x 1 x 2 x1x1 x2x2 x2x2 x1x1

20 3SAT P CLIQUE We transform a 3-cnf formula into G,k such that 3SAT G,k CLIQUE If has k clauses, we create a graph with k clusters of 3 nodes each. Each cluster corresponds to a clause. Each node in a cluster is labeled with a literal from the clause. We do not connect any nodes in the same cluster We connect nodes in different clusters whenever they are not contradictory

21 3SAT P CLIQUE We transform a 3-cnf formula into G,k such that 3SAT G,k CLIQUE is satisfiable iff there is an assignment that makes at least one literal true in each clause. The nodes corresponding to these k true literals do not contradict each other, so they form a k- clique in G. A k-clique in G must have one node from each cluster. Setting the corresponding literals to true will satisfy

22 VERTEX COVER b a e c d b a e c d Theorem: VERTEX-COVER is NP-Complete (1) VERTEX-COVER NP (2) CLIQUE P IND-SET P VERTEX-COVER

23 VERTEX-COVER = { G,k | G is an undirected graph with a k-node vertex cover } Theorem: VERTEX-COVER is NP-Complete (1) VERTEX-COVER NP (2) 3SAT P VERTEX-COVER

24 3SAT P VERTEX-COVER We transform a 3-cnf formula into G,k such that 3SAT G,k VERTEX-COVER The transformation can be done in time polynomial in the length of

25 (x 1 x 1 x 2 ) ( x 1 x 2 x 2 ) ( x 1 x 2 x 2 ) x1x1 x1x1 x2x2 x 1 x2x2 x2x2 x 2 x 1 x1x1 x2x2 x 2 k = 2(#clauses) + (#variables)

26 HAMILTONIAN PATHS b a e c d f h i g

27 HAMPATH = { G,s,t | G is a graph with a Hamiltonian path from s to t } Theorem: HAMPATH is NP-Complete (1) HAMPATH NP (2) 3SAT P HAMPATH

28 3SAT P HAMPATH We transform a 3-cnf formula into G,s,t so that 3SAT G,s,t HAMPATH The transformation can be done in time polynomial in the length of

29 (x 1 Ç x 2 Ç x 2 ) Æ (:x 1 Ç x 2 Ç x 2 ) stx1x1 x1x1 x2x2 x2x2

30 stx1x1 x1x1 x2x2 x2x2 c1c1 x 11 x 12 x 21 x 22

31 (x 1 Ç x 2 Ç x 2 ) Æ (:x 1 Ç x 2 Ç x 2 ) stx1x1 x1x1 x2x2 x2x2 c1c1 x 11 x 12 x 21 x 22 c2c2 x 14 x 15 x 24 x 25

32 3-COLORING b a e c db ac d b a e c d a bd

33 3SAT P 3COLOR We transform a 3-cnf formula into a graph G so 3SAT G 3COLOR The transformation can be done in time polynomial in the length of

34 F T ? (x 1 Ç x 2 Ç x 2 ) x2x2 x2x2 x1x1 x1x1

35 F T ? x2x2 x1x1 x1x1 x2x2 c 11 c 12 c 13 c 14 c 15 c 16

36 F T ? x2x2 (x 1 Ç x 2 Ç x 2 ) x1x1 x1x1 x2x2 c 11 c 12 c 13 c 14 c 15 c 16 c 11 c 12 c 13 c 14 c 15 c 16 Æ (x 2 Ç :x 1 Ç :x 1 )

37 F T ? x2x2 (x 1 Ç x 2 Ç x 2 ) x1x1 x1x1 x2x2 c 11 c 12 c 13 c 14 c 15 c 16 c 11 c 12 c 13 c 14 c 15 c 16 Æ (x 2 Ç :x 1 Ç :x 1 )

38 MORE GADGETS

39 MORE GADGETS


Download ppt "INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011."

Similar presentations


Ads by Google