algorithms and theory of computation lecture 20 reduction
play

Algorithms and Theory of Computation Lecture 20: Reduction, SAT - PowerPoint PPT Presentation

Algorithms and Theory of Computation Lecture 20: Reduction, SAT Xiaohui Bei MAS 714 October 27, 2020 Nanyang Technological University MAS 714 October 27, 2020 1 / 28 Recap P: set of decision problems that have polynomial time algorithms.


  1. Algorithms and Theory of Computation Lecture 20: Reduction, SAT Xiaohui Bei MAS 714 October 27, 2020 Nanyang Technological University MAS 714 October 27, 2020 1 / 28

  2. Recap P: set of decision problems that have polynomial time algorithms. NP: set of decision problems that have polynomial time nondeterministic algorithms. Big Question Does every problem in NP have an efficient algorithm? Same as asking whether P = NP. We don’t know the answer and many people believe that P � = NP. Nanyang Technological University MAS 714 October 27, 2020 2 / 28

  3. 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 . We use reductions to find algorithms to solve problems. show that we can’t find algorithms for some problems. (We say that these problems are hard.) Nanyang Technological University MAS 714 October 27, 2020 3 / 28

  4. Reductions for Decision Problems/Languages Reductions for Languages For languages L X , L Y , a reduction from L X to L Y is an algorithm with input w ∈ Σ ∗ output w ′ ∈ Σ ∗ such that w ′ ∈ L Y ⇐ ⇒ w ∈ L X (Actually, this is only one type of reduction, but this is the one we’ll use most often.) There are other kinds of reductions. Nanyang Technological University MAS 714 October 27, 2020 4 / 28

  5. Reductions for Decision Problems/Languages Reductions for Decision Problems For decision problems X, Y , a reduction from X to Y is an algorithm with input: I X , an instance of X output: I Y . an instance of Y such that I Y is YES instance of Y ⇐ ⇒ I X is YES instance of X Nanyang Technological University MAS 714 October 27, 2020 5 / 28

  6. Using Reductions to Solve Problems R : Reduction X → Y A Y : algorithm for Y New algorithm for X : Algorithm: A X ( I X ) : I Y = R ( I X ) ; return A Y ( I Y ) If R and A Y polynomial time = ⇒ A X polynomial time Nanyang Technological University MAS 714 October 27, 2020 6 / 28

  7. Comparing Problems If Problem X reduces to Problem Y (we write X ≤ Y ), then “Problem X is no harder to solve than Problem Y ”. X ≤ Y : X is no harder than Y , or Y is at least as hard as X . Nanyang Technological University MAS 714 October 27, 2020 7 / 28

  8. Example of Reductions Given a graph G , a set of vertices S is: independent set: no two vertices of S connected by an edge. clique: every pair of vertices in S is connected by an edge of G . Nanyang Technological University MAS 714 October 27, 2020 8 / 28

  9. Independent Set and Clique Problems Independent Set Instance: A graph G and an integer k . Question: Does G have an independent set of size ≥ k ? Clique Instance: A graph G and an integer k . Question: Does G have an clique of size ≥ k ? Nanyang Technological University MAS 714 October 27, 2020 9 / 28

  10. Recall For decision problems X, Y , a reduction from X to Y is an algorithm that takes I X , an instance of X as input and returns I Y , an instance of Y as output such that the solution (Y/N) to I Y is the same as the solution to I X . Nanyang Technological University MAS 714 October 27, 2020 10 / 28

  11. 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 . Nanyang Technological University MAS 714 October 27, 2020 11 / 28

  12. Correctness of Reduction Lemma G has an independent set of size at least k if and only if G has a clique of size at least k . Proof. Need to prove two facts: G has an 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 . Nanyang Technological University MAS 714 October 27, 2020 12 / 28

  13. Independent Set and Clique Independent Set ≤ Clique ◮ what does it mean? If we have an algorithm for Clique , then we have an algorithm for Independent Set . Clique is at least as hard as Independent Set . Also... we can use a similar argument to prove that Independent Set is at least as hard as Clique . Nanyang Technological University MAS 714 October 27, 2020 13 / 28

  14. Independent Set and Clique Assume you can solve the Clique problem in time T ( n ) , then you can solve the Independent Set problem in time (A) O ( T ( n )) (B) O ( n log n + T ( n )) (C) O ( n 2 T ( n 2 )) (D) O ( n 4 T ( n 4 )) (E) O ( n 2 + T ( n 2 )) (F) We don’t care – all these are polynomial if T ( n ) is a polynomial, which is good enough for our purposes. Nanyang Technological University MAS 714 October 27, 2020 14 / 28

  15. 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 . Nanyang Technological University MAS 714 October 27, 2020 15 / 28

  16. Polynomial Time Reductions For decision problems X, Y , a polynomial reduction from X to Y is an algorithm A that has the following properties: A takes I X , an instance of X as input returns I Y , an instance of Y as output runs in polynomial time such that the solution (Y/N) to I Y is the same as the solution to I X . 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. Nanyang Technological University MAS 714 October 27, 2020 16 / 28

  17. 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 . Nanyang Technological University MAS 714 October 27, 2020 17 / 28

  18. 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! Nanyang Technological University MAS 714 October 27, 2020 18 / 28

  19. The Satisfiability Problem (SAT) 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 A clause is a disjunction of literals. ◮ e.g. x 1 ∨ x 2 ∨ x 4 is a clause A formula in conjunctive normal form (CNF) is propositional formula which is a conjunction of clauses. ◮ ( x 1 ∨ x 2 ∨ x 4 ) ∧ ( x 2 ∨ x 3 ) ∧ x 5 is a CNF formula A formula ϕ is a 3CNF if every clause in ϕ has exactly 3 literals. ◮ ( x 1 ∨ x 2 ∨ x 4 ) ∧ ( x 2 ∨ x 3 ∨ x 1 ) is a 3CNF formula, but ( x 1 ∨ x 2 ∨ x 4 ) ∧ ( x 2 ∨ x 3 ) ∧ x 5 is not. Nanyang Technological University MAS 714 October 27, 2020 19 / 28

  20. Satisfiability SAT Instance : A CNF formula ϕ Question : Is there a truth assignment to the variable of ϕ such that ϕ evaluates to true? 3SAT Instance : A 3CNF formula ϕ Question : Is there a truth assignment to the variable of ϕ such that ϕ evaluates to true? Example 1 ( x 1 ∨ x 2 ∨ x 4 ) ∧ ( x 2 ∨ x 3 ) is satisfiable; take x 1 , . . . , x 4 to be all true. 2 ( x 1 ∨ x 2 ) ∧ ( x 1 ∨ x 2 ) ∧ ( x 1 ∨ x 2 ) ∧ ( x 1 ∨ x 2 ) is not satisfiable. Nanyang Technological University MAS 714 October 27, 2020 20 / 28

  21. Importance of SAT and 3SAT SAT and 3SAT are basic constraint satisfaction problems. Many different problems can reduced to them because of the simple yet powerful expressively of logical constraints. Arise naturally in many applications involving hardware and software verification and correctness. As we will see, it is a fundamental problem in theory of NP-Completeness. Nanyang Technological University MAS 714 October 27, 2020 21 / 28

  22. SAT vs. 3SAT Which problem is harder? It is easy to derive 3SAT ≤ P SAT SAT is at least as hard as 3SAT But the reverse direction is also true. Claim SAT ≤ P 3SAT Given ϕ as a SAT formula, we create a 3SAT formula ϕ ′ such that ϕ is satisfiable iff ϕ ′ is satisfiable ϕ ′ can be constructed from ϕ in time polynomial in | ϕ | Nanyang Technological University MAS 714 October 27, 2020 22 / 28

  23. SAT ≤ P 3SAT How SAT is different from 3SAT ? In SAT clauses might have arbitrary length: 1, 2, 3, . . . variables. In 3SAT every clause must have exactly 3 different literals. To reduce from an instance of SAT to an instance of 3SAT , we must make all clauses to have exactly 3 literals. Basic Idea: 1 Pad short clauses so they have 3 literals. 2 Break long clauses into shorter clauses. 3 Repeat the above till we have a 3CNF. Nanyang Technological University MAS 714 October 27, 2020 23 / 28

Recommend


More recommend