np and polynomial time reductions
play

NP and Polynomial Time Reductions Lecture 23 November 17, 2015 - PowerPoint PPT Presentation

CS 374: Algorithms & Models of Computation, Fall 2015 NP and Polynomial Time Reductions Lecture 23 November 17, 2015 Chandra & Manoj (UIUC) CS374 1 Fall 2015 1 / 64 Part I NP, Showing Problems to be in NP Chandra & Manoj


  1. Reductions A reduction from Problem X to Problem Y means (informally) that if we have an algorithm for Problem Y , we can use it to find an algorithm for Problem X . Using Reductions We use reductions to find algorithms to solve problems. 1 Chandra & Manoj (UIUC) CS374 17 Fall 2015 17 / 64

  2. Reductions A reduction from Problem X to Problem Y means (informally) that if we have an algorithm for Problem Y , we can use it to find an algorithm for Problem X . Using Reductions We use reductions to find algorithms to solve problems. 1 We also use reductions to show that we can’t find algorithms for 2 some problems. (We say that these problems are hard.) Chandra & Manoj (UIUC) CS374 17 Fall 2015 17 / 64

  3. Reductions for decision problems/languages For languages L X , L Y , a reduction from L X to L Y is: An algorithm . . . 1 Input: w ∈ Σ ∗ 2 Output: w ′ ∈ Σ ∗ 3 Such that: 4 w ′ ∈ L X w ∈ L Y ⇐ ⇒ Chandra & Manoj (UIUC) CS374 18 Fall 2015 18 / 64

  4. Reductions for decision problems/languages For languages L X , L Y , a reduction from L X to L Y is: An algorithm . . . 1 Input: w ∈ Σ ∗ 2 Output: w ′ ∈ Σ ∗ 3 Such that: 4 w ′ ∈ L X w ∈ L Y ⇐ ⇒ (Actually, this is only one type of reduction, but this is the one we’ll use most often.) There are other kinds of reductions. Chandra & Manoj (UIUC) CS374 18 Fall 2015 18 / 64

  5. Reductions for decision problems/languages For decision problems X , Y , a reduction from X to Y is: An algorithm . . . 1 Input: I X , an instance of X . 2 Output: I Y an instance of Y . 3 Such that: 4 I Y is YES instance of Y ⇐ ⇒ I X is YES instance of X Chandra & Manoj (UIUC) CS374 19 Fall 2015 19 / 64

  6. Using reductions to solve problems R : Reduction X → Y 1 A Y : algorithm for Y : 2 Chandra & Manoj (UIUC) CS374 20 Fall 2015 20 / 64

  7. Using reductions to solve problems R : Reduction X → Y 1 A Y : algorithm for Y : 2 = ⇒ New algorithm for X : 3 A X ( I X ) : // I X : instance of X . I Y ⇐ R ( I X ) return A Y ( I Y ) Chandra & Manoj (UIUC) CS374 20 Fall 2015 20 / 64

  8. Using reductions to solve problems R : Reduction X → Y 1 A Y : algorithm for Y : 2 = ⇒ New algorithm for X : 3 A X ( I X ) : // I X : instance of X . I Y ⇐ R ( I X ) return A Y ( I Y ) YES I X I Y R A Y NO A X If R and A Y polynomial-time = ⇒ A X polynomial-time. Chandra & Manoj (UIUC) CS374 20 Fall 2015 20 / 64

  9. Comparing Problems “Problem X is no harder to solve than Problem Y ”. 1 If Problem X reduces to Problem Y (we write X ≤ Y ), then 2 X cannot be harder to solve than Y . X ≤ Y : 3 X is no harder than Y , or 1 Y is at least as hard as X . 2 Chandra & Manoj (UIUC) CS374 21 Fall 2015 21 / 64

  10. Part III Examples of Reductions Chandra & Manoj (UIUC) CS374 22 Fall 2015 22 / 64

  11. Independent Sets and Cliques Given a graph G , a set of vertices V ′ is: Chandra & Manoj (UIUC) CS374 23 Fall 2015 23 / 64

  12. Independent Sets and Cliques Given a graph G , a set of vertices V ′ is: independent set : no two vertices of V ′ connected by an edge. 1 Chandra & Manoj (UIUC) CS374 23 Fall 2015 23 / 64

  13. Independent Sets and Cliques Given a graph G , a set of vertices V ′ is: independent set : no two vertices of V ′ connected by an edge. 1 clique : every pair of vertices in V ′ is connected by an edge of 2 G . Chandra & Manoj (UIUC) CS374 23 Fall 2015 23 / 64

  14. Independent Sets and Cliques Given a graph G , a set of vertices V ′ is: independent set : no two vertices of V ′ connected by an edge. 1 clique : every pair of vertices in V ′ is connected by an edge of 2 G . Chandra & Manoj (UIUC) CS374 23 Fall 2015 23 / 64

  15. Independent Sets and Cliques Given a graph G , a set of vertices V ′ is: independent set : no two vertices of V ′ connected by an edge. 1 clique : every pair of vertices in V ′ is connected by an edge of 2 G . Chandra & Manoj (UIUC) CS374 23 Fall 2015 23 / 64

  16. Independent Sets and Cliques Given a graph G , a set of vertices V ′ is: independent set : no two vertices of V ′ connected by an edge. 1 clique : every pair of vertices in V ′ is connected by an edge of 2 G . Chandra & Manoj (UIUC) CS374 23 Fall 2015 23 / 64

  17. The Independent Set and Clique Problems Problem: Independent Set Instance: A graph G and an integer k . Question: Does G has an independent set of size ≥ k ? Chandra & Manoj (UIUC) CS374 24 Fall 2015 24 / 64

  18. The Independent Set and Clique Problems Problem: Independent Set Instance: A graph G and an integer k . Question: Does G has an independent set of size ≥ k ? Problem: Clique Instance: A graph G and an integer k . Question: Does G has a clique of size ≥ k ? Chandra & Manoj (UIUC) CS374 24 Fall 2015 24 / 64

  19. Recall For decision problems X , Y , a reduction from X to Y is: An algorithm . . . 1 that takes I X , an instance of X as input . . . 2 and returns I Y , an instance of Y as output . . . 3 such that the solution (YES/NO) to I Y is the same as the 4 solution to I X . Chandra & Manoj (UIUC) CS374 25 Fall 2015 25 / 64

  20. Reducing Independent Set to Clique An instance of Independent Set is a graph G and an integer k . Chandra & Manoj (UIUC) CS374 26 Fall 2015 26 / 64

  21. Reducing Independent Set to Clique An instance of Independent Set is a graph G and an integer k . Chandra & Manoj (UIUC) CS374 26 Fall 2015 26 / 64

  22. Reducing Independent Set to Clique An instance of Independent Set is a graph G and an integer k . Reduction given < G , k > outputs < G , k > where G is the complement of G . G has an edge ( u , v ) if and only if ( u , v ) is not an edge of G . Chandra & Manoj (UIUC) CS374 26 Fall 2015 26 / 64

  23. Reducing Independent Set to Clique An instance of Independent Set is a graph G and an integer k . Reduction given < G , k > outputs < G , k > where G is the complement of G . G has an edge ( u , v ) if and only if ( u , v ) is not an edge of G . Chandra & Manoj (UIUC) CS374 26 Fall 2015 26 / 64

  24. Reducing Independent Set to Clique An instance of Independent Set is a graph G and an integer k . Reduction given < G , k > outputs < G , k > where G is the complement of G . G has an edge ( u , v ) if and only if ( u , v ) is not an edge of G . Chandra & Manoj (UIUC) CS374 26 Fall 2015 26 / 64

  25. Reducing Independent Set to Clique An instance of Independent Set is a graph G and an integer k . Reduction given < G , k > outputs < G , k > where G is the complement of G . G has an edge ( u , v ) if and only if ( u , v ) is not an edge of G . Chandra & Manoj (UIUC) CS374 26 Fall 2015 26 / 64

  26. Correctness of reduction Lemma G has an independent set of size k if and only if G has a clique of size k . Proof. Need to prove two facts: G has independent set of size at least k implies that G has a clique of size at least k . G has a clique of size at least k implies that G has an independent set of size at least k . Easy to see both from the fact that S ⊆ V is an independent set in G if and only if S is a clique in G . Chandra & Manoj (UIUC) CS374 27 Fall 2015 27 / 64

  27. Independent Set and Clique Independent Set ≤ Clique . 1 Chandra & Manoj (UIUC) CS374 28 Fall 2015 28 / 64

  28. Independent Set and Clique Independent Set ≤ Clique . 1 What does this mean? If have an algorithm for Clique , then we have an algorithm for 2 Independent Set . Chandra & Manoj (UIUC) CS374 28 Fall 2015 28 / 64

  29. Independent Set and Clique Independent Set ≤ Clique . 1 What does this mean? If have an algorithm for Clique , then we have an algorithm for 2 Independent Set . Clique is at least as hard as Independent Set . 3 Chandra & Manoj (UIUC) CS374 28 Fall 2015 28 / 64

  30. Independent Set and Clique Independent Set ≤ Clique . 1 What does this mean? If have an algorithm for Clique , then we have an algorithm for 2 Independent Set . Clique is at least as hard as Independent Set . 3 Also... Clique ≤ Independent Set . Why? Thus Clique and 4 Independent Set are polnomial-time equivalent. Chandra & Manoj (UIUC) CS374 28 Fall 2015 28 / 64

  31. Independent Set and Clique Assume you can solve the Clique problem in T ( n ) time. Then you can solve the Independent Set problem in (A) O ( T ( n )) time. (B) O ( n log n + T ( n )) time. (C) O ( n 2 T ( n 2 )) time. (D) O ( n 4 T ( n 4 )) time. (E) O ( n 2 + T ( n 2 )) time. (F) Does not matter - all these are polynomial if T ( n ) is polynomial, which is good enough for our purposes. Chandra & Manoj (UIUC) CS374 29 Fall 2015 29 / 64

  32. DFA Universality A DFA M is universal if it accepts every string. That is, L ( M ) = Σ ∗ , the set of all strings. Chandra & Manoj (UIUC) CS374 30 Fall 2015 30 / 64

  33. DFA Universality A DFA M is universal if it accepts every string. That is, L ( M ) = Σ ∗ , the set of all strings. Problem ( DFA universality ) Input: A DFA M . Goal: Is M universal? Chandra & Manoj (UIUC) CS374 30 Fall 2015 30 / 64

  34. DFA Universality A DFA M is universal if it accepts every string. That is, L ( M ) = Σ ∗ , the set of all strings. Problem ( DFA universality ) Input: A DFA M . Goal: Is M universal? How do we solve DFA Universality ? Chandra & Manoj (UIUC) CS374 30 Fall 2015 30 / 64

  35. DFA Universality A DFA M is universal if it accepts every string. That is, L ( M ) = Σ ∗ , the set of all strings. Problem ( DFA universality ) Input: A DFA M . Goal: Is M universal? How do we solve DFA Universality ? We check if M has any reachable non-final state. Chandra & Manoj (UIUC) CS374 30 Fall 2015 30 / 64

  36. NFA Universality An NFA N is said to be universal if it accepts every string. That is, L ( N ) = Σ ∗ , the set of all strings. Problem ( NFA universality ) Input: A NFA M . Goal: Is M universal? How do we solve NFA Universality ? Chandra & Manoj (UIUC) CS374 31 Fall 2015 31 / 64

  37. NFA Universality An NFA N is said to be universal if it accepts every string. That is, L ( N ) = Σ ∗ , the set of all strings. Problem ( NFA universality ) Input: A NFA M . Goal: Is M universal? How do we solve NFA Universality ? Reduce it to DFA Universality ? Chandra & Manoj (UIUC) CS374 31 Fall 2015 31 / 64

  38. NFA Universality An NFA N is said to be universal if it accepts every string. That is, L ( N ) = Σ ∗ , the set of all strings. Problem ( NFA universality ) Input: A NFA M . Goal: Is M universal? How do we solve NFA Universality ? Reduce it to DFA Universality ? Given an NFA N , convert it to an equivalent DFA M , and use the DFA Universality Algorithm. Chandra & Manoj (UIUC) CS374 31 Fall 2015 31 / 64

  39. NFA Universality An NFA N is said to be universal if it accepts every string. That is, L ( N ) = Σ ∗ , the set of all strings. Problem ( NFA universality ) Input: A NFA M . Goal: Is M universal? How do we solve NFA Universality ? Reduce it to DFA Universality ? Given an NFA N , convert it to an equivalent DFA M , and use the DFA Universality Algorithm. The reduction takes exponential time! NFA Universality is known to be PSPACE-Complete and we do not expect a polynomial-time algorithm. Chandra & Manoj (UIUC) CS374 31 Fall 2015 31 / 64

  40. Polynomial-time reductions We say that an algorithm is efficient if it runs in polynomial-time. Chandra & Manoj (UIUC) CS374 32 Fall 2015 32 / 64

  41. Polynomial-time reductions We say that an algorithm is efficient if it runs in polynomial-time. To find efficient algorithms for problems, we are only interested in polynomial-time reductions. Reductions that take longer are not useful. Chandra & Manoj (UIUC) CS374 32 Fall 2015 32 / 64

  42. Polynomial-time reductions We say that an algorithm is efficient if it runs in polynomial-time. To find efficient algorithms for problems, we are only interested in polynomial-time reductions. Reductions that take longer are not useful. If we have a polynomial-time reduction from problem X to problem Y (we write X ≤ P Y ), and a poly-time algorithm A Y for Y , we have a polynomial-time/efficient algorithm for X . Chandra & Manoj (UIUC) CS374 32 Fall 2015 32 / 64

  43. Polynomial-time reductions We say that an algorithm is efficient if it runs in polynomial-time. To find efficient algorithms for problems, we are only interested in polynomial-time reductions. Reductions that take longer are not useful. If we have a polynomial-time reduction from problem X to problem Y (we write X ≤ P Y ), and a poly-time algorithm A Y for Y , we have a polynomial-time/efficient algorithm for X . YES I Y I X A Y R NO A x Chandra & Manoj (UIUC) CS374 32 Fall 2015 32 / 64

  44. Polynomial-time Reduction A polynomial time reduction from a decision problem X to a decision problem Y is an algorithm A that has the following properties: given an instance I X of X , A produces an instance I Y of Y 1 A runs in time polynomial in | I X | . 2 Answer to I X YES iff answer to I Y is YES. 3 Proposition If X ≤ P Y then a polynomial time algorithm for Y implies a polynomial time algorithm for X . Such a reduction is called a Karp reduction . Most reductions we will need are Karp reductions.Karp reductions are the same as mapping reductions when specialized to polynomial time for the reduction step. Chandra & Manoj (UIUC) CS374 33 Fall 2015 33 / 64

  45. Reductions again... Let X and Y be two decision problems, such that X can be solved in polynomial time, and X ≤ P Y . Then (A) Y can be solved in polynomial time. (B) Y can NOT be solved in polynomial time. (C) If Y is hard then X is also hard. (D) None of the above. (E) All of the above. Chandra & Manoj (UIUC) CS374 34 Fall 2015 34 / 64

  46. Polynomial-time reductions and hardness For decision problems X and Y , if X ≤ P Y , and Y has an efficient algorithm, X has an efficient algorithm. Chandra & Manoj (UIUC) CS374 35 Fall 2015 35 / 64

  47. Polynomial-time reductions and hardness For decision problems X and Y , if X ≤ P Y , and Y has an efficient algorithm, X has an efficient algorithm. If you believe that Independent Set does not have an efficient algorithm, why should you believe the same of Clique ? Chandra & Manoj (UIUC) CS374 35 Fall 2015 35 / 64

  48. Polynomial-time reductions and hardness For decision problems X and Y , if X ≤ P Y , and Y has an efficient algorithm, X has an efficient algorithm. If you believe that Independent Set does not have an efficient algorithm, why should you believe the same of Clique ? Because we showed Independent Set ≤ P Clique . If Clique had an efficient algorithm, so would Independent Set ! Chandra & Manoj (UIUC) CS374 35 Fall 2015 35 / 64

  49. Polynomial-time reductions and hardness For decision problems X and Y , if X ≤ P Y , and Y has an efficient algorithm, X has an efficient algorithm. If you believe that Independent Set does not have an efficient algorithm, why should you believe the same of Clique ? Because we showed Independent Set ≤ P Clique . If Clique had an efficient algorithm, so would Independent Set ! If X ≤ P Y and X does not have an efficient algorithm, Y cannot have an efficient algorithm! Chandra & Manoj (UIUC) CS374 35 Fall 2015 35 / 64

  50. Polynomial-time reductions and instance sizes Proposition Let R be a polynomial-time reduction from X to Y . Then for any instance I X of X , the size of the instance I Y of Y produced from I X by R is polynomial in the size of I X . Chandra & Manoj (UIUC) CS374 36 Fall 2015 36 / 64

  51. Polynomial-time reductions and instance sizes Proposition Let R be a polynomial-time reduction from X to Y . Then for any instance I X of X , the size of the instance I Y of Y produced from I X by R is polynomial in the size of I X . Proof. R is a polynomial-time algorithm and hence on input I X of size | I X | it runs in time p ( | I X | ) for some polynomial p () . I Y is the output of R on input I X . R can write at most p ( | I X | ) bits and hence | I Y | ≤ p ( | I X | ) . Chandra & Manoj (UIUC) CS374 36 Fall 2015 36 / 64

  52. Polynomial-time reductions and instance sizes Proposition Let R be a polynomial-time reduction from X to Y . Then for any instance I X of X , the size of the instance I Y of Y produced from I X by R is polynomial in the size of I X . Proof. R is a polynomial-time algorithm and hence on input I X of size | I X | it runs in time p ( | I X | ) for some polynomial p () . I Y is the output of R on input I X . R can write at most p ( | I X | ) bits and hence | I Y | ≤ p ( | I X | ) . Note: Converse is not true. A reduction need not be polynomial-time even if output of reduction is of size polynomial in its input. Chandra & Manoj (UIUC) CS374 36 Fall 2015 36 / 64

  53. Polynomial-time Reduction A polynomial time reduction from a decision problem X to a decision problem Y is an algorithm A that has the following properties: Given an instance I X of X , A produces an instance I Y of Y . 1 A runs in time polynomial in | I X | . This implies that | I Y | (size of 2 I Y ) is polynomial in | I X | . Answer to I X YES iff answer to I Y is YES. 3 Proposition If X ≤ P Y then a polynomial time algorithm for Y implies a polynomial time algorithm for X . Chandra & Manoj (UIUC) CS374 37 Fall 2015 37 / 64

  54. Transitivity of Reductions Proposition X ≤ P Y and Y ≤ P Z implies that X ≤ P Z . Note: X ≤ P Y does not imply that Y ≤ P X and hence it is very important to know the FROM and TO in a reduction. To prove X ≤ P Y you need to show a reduction FROM X TO Y That is, show that an algorithm for Y implies an algorithm for X . Chandra & Manoj (UIUC) CS374 38 Fall 2015 38 / 64

  55. Vertex Cover Given a graph G = ( V , E ) , a set of vertices S is: Chandra & Manoj (UIUC) CS374 39 Fall 2015 39 / 64

  56. Vertex Cover Given a graph G = ( V , E ) , a set of vertices S is: A vertex cover if every e ∈ E has at least one endpoint in S . 1 Chandra & Manoj (UIUC) CS374 39 Fall 2015 39 / 64

  57. Vertex Cover Given a graph G = ( V , E ) , a set of vertices S is: A vertex cover if every e ∈ E has at least one endpoint in S . 1 Chandra & Manoj (UIUC) CS374 39 Fall 2015 39 / 64

  58. Vertex Cover Given a graph G = ( V , E ) , a set of vertices S is: A vertex cover if every e ∈ E has at least one endpoint in S . 1 Chandra & Manoj (UIUC) CS374 39 Fall 2015 39 / 64

  59. Vertex Cover Given a graph G = ( V , E ) , a set of vertices S is: A vertex cover if every e ∈ E has at least one endpoint in S . 1 Chandra & Manoj (UIUC) CS374 39 Fall 2015 39 / 64

  60. The Vertex Cover Problem Problem ( Vertex Cover ) Input: A graph G and integer k . Goal: Is there a vertex cover of size ≤ k in G? Chandra & Manoj (UIUC) CS374 40 Fall 2015 40 / 64

  61. The Vertex Cover Problem Problem ( Vertex Cover ) Input: A graph G and integer k . Goal: Is there a vertex cover of size ≤ k in G? Can we relate Independent Set and Vertex Cover ? Chandra & Manoj (UIUC) CS374 40 Fall 2015 40 / 64

  62. Relationship between... Vertex Cover and Independent Set Proposition Let G = ( V , E ) be a graph. S is an independent set if and only if V \ S is a vertex cover. Proof. ( ⇒ ) Let S be an independent set Consider any edge uv ∈ E . 1 Since S is an independent set, either u �∈ S or v �∈ S . 2 Thus, either u ∈ V \ S or v ∈ V \ S . 3 V \ S is a vertex cover. 4 ( ⇐ ) Let V \ S be some vertex cover: Consider u , v ∈ S 1 uv is not an edge of G, as otherwise V \ S does not cover uv . 2 = ⇒ S is thus an independent set. 3 Chandra & Manoj (UIUC) CS374 41 Fall 2015 41 / 64

  63. Independent Set ≤ P Vertex Cover G : graph with n vertices, and an integer k be an instance of the 1 Independent Set problem. Chandra & Manoj (UIUC) CS374 42 Fall 2015 42 / 64

  64. Independent Set ≤ P Vertex Cover G : graph with n vertices, and an integer k be an instance of the 1 Independent Set problem. G has an independent set of size ≥ k iff G has a vertex cover 2 of size ≤ n − k Chandra & Manoj (UIUC) CS374 42 Fall 2015 42 / 64

  65. Independent Set ≤ P Vertex Cover G : graph with n vertices, and an integer k be an instance of the 1 Independent Set problem. G has an independent set of size ≥ k iff G has a vertex cover 2 of size ≤ n − k ( G , k ) is an instance of Independent Set , and ( G , n − k ) is 3 an instance of Vertex Cover with the same answer. Chandra & Manoj (UIUC) CS374 42 Fall 2015 42 / 64

  66. Independent Set ≤ P Vertex Cover G : graph with n vertices, and an integer k be an instance of the 1 Independent Set problem. G has an independent set of size ≥ k iff G has a vertex cover 2 of size ≤ n − k ( G , k ) is an instance of Independent Set , and ( G , n − k ) is 3 an instance of Vertex Cover with the same answer. Therefore, Independent Set ≤ P Vertex Cover . Also Vertex 4 Cover ≤ P Independent Set . Chandra & Manoj (UIUC) CS374 42 Fall 2015 42 / 64

  67. Proving Correctness of Reductions To prove that X ≤ P Y you need to give an algorithm A that: Transforms an instance I X of X into an instance I Y of Y . 1 Satisfies the property that answer to I X is YES iff I Y is YES. 2 typical easy direction to prove: answer to I Y is YES if answer to 1 I X is YES typical difficult direction to prove: answer to I X is YES if 2 answer to I Y is YES (equivalently answer to I X is NO if answer to I Y is NO). Runs in polynomial time. 3 Chandra & Manoj (UIUC) CS374 43 Fall 2015 43 / 64

  68. Part IV The Satisfiability Problem (SAT) Chandra & Manoj (UIUC) CS374 44 Fall 2015 44 / 64

  69. Propositional Formulas Definition Consider a set of boolean variables x 1 , x 2 , . . . x n . A literal is either a boolean variable x i or its negation ¬ x i . 1 A clause is a disjunction of literals. 2 For example, x 1 ∨ x 2 ∨ ¬ x 4 is a clause. A formula in conjunctive normal form ( CNF ) is 3 propositional formula which is a conjunction of clauses ( x 1 ∨ x 2 ∨ ¬ x 4 ) ∧ ( x 2 ∨ ¬ x 3 ) ∧ x 5 is a CNF formula. 1 Chandra & Manoj (UIUC) CS374 45 Fall 2015 45 / 64

  70. Propositional Formulas Definition Consider a set of boolean variables x 1 , x 2 , . . . x n . A literal is either a boolean variable x i or its negation ¬ x i . 1 A clause is a disjunction of literals. 2 For example, x 1 ∨ x 2 ∨ ¬ x 4 is a clause. A formula in conjunctive normal form ( CNF ) is 3 propositional formula which is a conjunction of clauses ( x 1 ∨ x 2 ∨ ¬ x 4 ) ∧ ( x 2 ∨ ¬ x 3 ) ∧ x 5 is a CNF formula. 1 A formula ϕ is a 3CNF : 4 A CNF formula such that every clause has exactly 3 literals. ( x 1 ∨ x 2 ∨ ¬ x 4 ) ∧ ( x 2 ∨ ¬ x 3 ∨ x 1 ) is a 3CNF formula, but 1 ( x 1 ∨ x 2 ∨ ¬ x 4 ) ∧ ( x 2 ∨ ¬ x 3 ) ∧ x 5 is not. Chandra & Manoj (UIUC) CS374 45 Fall 2015 45 / 64

  71. Satisfiability Problem: SAT Instance: A CNF formula ϕ . Question: Is there a truth assignment to the variable of ϕ such that ϕ evaluates to true? Problem: 3SAT Instance: A 3CNF formula ϕ . Question: Is there a truth assignment to the variable of ϕ such that ϕ evaluates to true? Chandra & Manoj (UIUC) CS374 46 Fall 2015 46 / 64

  72. Satisfiability SAT Given a CNF formula ϕ , is there a truth assignment to variables such that ϕ evaluates to true? Example ( x 1 ∨ x 2 ∨ ¬ x 4 ) ∧ ( x 2 ∨ ¬ x 3 ) ∧ x 5 is satisfiable; take 1 x 1 , x 2 , . . . x 5 to be all true ( x 1 ∨ ¬ x 2 ) ∧ ( ¬ x 1 ∨ x 2 ) ∧ ( ¬ x 1 ∨ ¬ x 2 ) ∧ ( x 1 ∨ x 2 ) is not 2 satisfiable. 3SAT Given a 3CNF formula ϕ , is there a truth assignment to variables such that ϕ evaluates to true? (More on 2SAT in a bit...) Chandra & Manoj (UIUC) CS374 47 Fall 2015 47 / 64

  73. Importance of SAT and 3SAT SAT and 3SAT are basic constraint satisfaction problems. 1 Many different problems can reduced to them because of the 2 simple yet powerful expressively of logical constraints. Arise naturally in many applications involving hardware and 3 software verification and correctness. As we will see, it is a fundamental problem in theory of 4 NP-Complete ness. Chandra & Manoj (UIUC) CS374 48 Fall 2015 48 / 64

  74. z = x Given two bits x , z which of the following SAT formulas is equivalent to the formula z = x : (A) ( z ∨ x ) ∧ ( z ∨ x ) . (B) ( z ∨ x ) ∧ ( z ∨ x ) . (C) ( z ∨ x ) ∧ ( z ∨ x ) ∧ ( z ∨ x ) . (D) z ⊕ x . (E) ( z ∨ x ) ∧ ( z ∨ x ) ∧ ( z ∨ x ) ∧ ( z ∨ x ) . Chandra & Manoj (UIUC) CS374 49 Fall 2015 49 / 64

  75. z = x ∧ y Given three bits x , y , z which of the following SAT formulas is equivalent to the formula z = x ∧ y : (A) ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) . (B) ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) . (C) ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) . (D) ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) . (E) ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) . Chandra & Manoj (UIUC) CS374 50 Fall 2015 50 / 64

  76. z = x ∨ y Given three bits x , y , z which of the following SAT formulas is equivalent to the formula z = x ∨ y : (A) ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) . (B) ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) . (C) ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) . (D) ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) . (E) ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) ∧ ( z ∨ x ∨ y ) . Chandra & Manoj (UIUC) CS374 51 Fall 2015 51 / 64

Recommend


More recommend