Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 23 NP-Hard Problems

Similar presentations


Presentation on theme: "Lecture 23 NP-Hard Problems"— Presentation transcript:

1 Lecture 23 NP-Hard Problems

2 Outline NP, NP-hard, NP-complete
Cook-Levin Theorem, first NP-hard problems Reductions INDEPENDENT SET to CLIQUE 3-SAT to INDEPENDENT SET

3 NP-hard problems A problem A is NP-hard, if for all problem B in NP, B can be reduced to A in polynomial time. A is “harder” than all problems in NP, hence NP-hard. A problem A is NP-complete, if it is in NP and also NP-hard. NP-hard but not NP-complete? May not be a decision problem, e.g. longest path. May be even harder than NP-complete problems.

4 Relationships NP-hard NP NP-complete P

5 NP-complete problems Claim: All NP-complete problems are equally hard. For any two NP-complete problems A, B, A can be reduced to B and B can be reduced to A. Claim: If any NP-complete problem has a polynomial time algorithm, then P = NP. Claim: If A can be reduced to B, B can be reduced to C, then A can be reduced to C. How do we prove a problem is NP-complete?

6 Outline NP, NP-hard, NP-complete
Cook-Levin Theorem, first NP-hard problems Reductions INDEPENDENT SET to CLIQUE 3-SAT to INDEPENDENT SET

7 The first NP-complete problem
Gates Circuits

8 CIRCUIT-SAT problem Given a circuit with n inputs and 1 output, is there a possible input (represented by n-bit binary string) that makes the output 1? Clearly in NP: Prover gives the input as an n-bit string, Verifier follows the circuit and computes the output, check that it is indeed 1. Theorem[Cook-Levin] CIRCUIT-SAT is NP-complete.

9 Proof idea of Cook-Levin
Verify(color[]) //color[] is an array with 0,1,2 FOR each edge (u,v) IF color[u]<>color[v] THEN RETURN FALSE RETURN TRUE NP-hard problem Verifier

10 Proof idea of Cook-Levin
Verify(color[]) //color[] is an array with 0,1,2 FOR each edge (u,v) IF color[u]<>color[v] THEN RETURN FALSE RETURN TRUE Machine code Compiler CIRCUIT-SAT instance! Input: binary encoding of color[] Output: True/False

11 Outline NP, NP-hard, NP-complete
Cook-Levin Theorem, first NP-hard problems Reductions INDEPENDENT SET to CLIQUE 3-SAT to INDEPENDENT SET

12 Other NP-hard Problems
Reduction NP-Hard NP-Hard A is NP-hard  For any problem C in NP, C is easier than A. A can be reduced to B  A is easier than B For any problem C in NP, C is easier than B  B is NP-hard

13 General Recipe for reductions
In order to prove B is NP-hard, given that we know A is NP hard. Reduce A to B. What is a complete reduction? Given an instance X of A, construct an instance Y of B. Prove that if answer to X is YES, answer to Y is also YES. Prove that if answer to X is NO, answer to Y is also NO. (Usually: prove the contrapositive: if answer to Y is YES, answer to X is also YES)

14 INDEPENDENT SET Given a graph, decide whether there is a set of k vertices, such that no two vertices in the set are connected by an edge.

15 CLIQUE Given a graph, decide whether there is a set of k vertices, such that all pairs of vertices in the set are connected by an edge. Claim: INDEPENDENT SET can be reduced to CLIQUE.

16 Reduction from INDEPENDENT SET to CLIQUE
Step 1: Given an instance X of INDEPENDENT SET, construct an instance Y of CLIQUE. Idea: Find similarities/differences of the problems. INDEP. SET: find vertices such that they are not connected. CLIQUE: find vertices such that they are connected.

17 3-SAT Literals: A variable ( 𝑥 1 ), or the negation of a variable ( 𝑥 1 ). Clause: Logic OR of literals ( 𝑥 1 ∨ 𝑥 3 ∨ 𝑥 5 ) Conjunctive Normal Form: “and” of “or”s. 𝑥 1 ∨ 𝑥 3 ∨ 𝑥 5 ∧ 𝑥 2 ∨ 𝑥 3 ∨ 𝑥 4 ∧⋯∧ 𝑥 1 ∨ 𝑥 4 ∨ 𝑥 5 3-SAT: Given a conjunctive normal form, where each clause contains at most 3 literals, decide whether there is a value of variables such that the formula is satisfied (A clause is satisfied if one of its literals is true; The formula is satisfied if ALL clauses are satisfied.)

18 Reduction from 3-SAT to INDEPENDENT SET
Step 1: Given an instance X of 3-SAT, construct an instance Y of INDEPENDENT SET. Problem: the two problems look totally different. Idea: Construct “Gadgets”: for each concept in 3- SAT (variables, clauses), construct a part of instance of INDEP. SET (some vertices/edges) so that we can connect the two problems.

19 Gadget for variables ui vi Variable xi: either true or false
Gadget: A graph with two different independent sets, corresponding to xi = true or false. Many constructions, but easiest one Hope: ui in independent set  xi = true vi in independent set  xi = false ui vi

20 Gadget for Clauses Clause: ( 𝑥 1 ∨ 𝑥 3 ∨ 𝑥 5 )
Interpretation: x1 = true or x3 = true or x5 = false  not all of v1, v3, u5 in independent set Idea: construct a gadget that connects to v1, v3, u5, such that when they are not all in independent set, we can put one vertex in gadget to indep. set; when they are all in indep. set, then we cannot put any vertex in gadget into indep set.

21 Gadget for Clauses Clause: ( 𝑥 1 ∨ 𝑥 3 ∨ 𝑥 5 ) Goal:
When clause is not satisfied, cannot select any vertex in gadget. When clause is satisfied, can select exactly one vertex in gadget This encourages all the clauses to be satisfied. Gadget v1 v3 u5

22 Gadget for Clauses Clause: ( 𝑥 1 ∨ 𝑥 3 ∨ 𝑥 5 ) Goal:
When clause is not satisfied, cannot select any vertex in gadget. When clause is satisfied, can select exactly one vertex in gadget This encourages all the clauses to be satisfied. v1 w1 v3 w2 u5 w3

23 Reductions Claim: CIRCUIT-SAT can be reduced to 3-SAT. (therefore 3-SAT is also NP-complete). Claim: 3-SAT can be reduced to INDEPENDENT SET. CIRCUIT-SAT 3-SAT IND-SET CLIQUE NP-complete NP-complete NP-complete NP-complete


Download ppt "Lecture 23 NP-Hard Problems"

Similar presentations


Ads by Google