Docsity

Advanced Computational Complexity-Lecture 06 Slides-Computer Science, Slides of Advanced Computational Complexity

Partial preview of the text

Download Advanced Computational Complexity-Lecture 06 Slides-Computer Science and more Slides Advanced Computational Complexity in PDF only on Docsity!

Lecture 6: NP-completeness I

Matthew Johnson

[email protected]

NP -completeness proofs

To prove that a problem Π is NP -complete we now just have to perform two steps:

  1. Show that Π belongs to NP
  2. Find a known NP -complete problem Π′^ and show Π′^ ≤ Π

Thousands of problems have now been shown to be NP -complete (for an early survey see Garey and Johnson). Note: If we can complete Step 2 but not Step 1, then we say that Π is NP -hard

NP-completeness of CLIQUE

The problem CLIQUE is in NP (the list of vertices in the clique is the certificate) To show that CLIQUE is NP -complete we shall reduce SATISFIABILITY to CLIQUE Given a formula f with clauses C 1 , C 2 ,... , Ck — For each literal x in clause Cj create a vertex — Put an edge between every pair of vertices from distinct clauses, unless they are incompatible (i.e. x and ¬x) This construction can be carried out in polynomial time The resulting graph has a clique of size k if and only if f is satisfiable (assign the value TRUE to every literal occurring in the clique)

Example construction

NP-completeness of VERTEX COVER

VERTEX COVER

Instance : A graph G = (V , E), and a natural number k. Question: Is there a set W ⊆ V , with |W | ≤ k, such that for each edge (i, j) ∈ E, {i, j} ∩ W 6 = ∅

The problem VERTEX COVER is in NP (the list of vertices in the clique is the certificate)

To show that VERTEX COVER is NP -complete we shall reduce SATISFIABILITY to VERTEX COVER

NP-completeness of VERTEX COVER

Given a formula f with clauses C 1 , C 2 ,... , Cm For each variable x create two adjacent vertices xf^ and xt to represent the literals x and ¬x For each clause Cj of size nj create a complete subgraph Gj with vertices connected to corresponding literals Set k = n + ∑mj= 1 (nj − 1 ) This construction can be carried out in polynomial time

Example construction

NP-completeness of VERTEX COVER

At least one of each pair (xf^ , xt^ ) must be in the cover At least nj − 1 vertices from each complete graph Gj must be in the cover If the formula is satisfiable, then choose the cover by choosing each literal assigned TRUE plus all but one vertex in each Gj. (Omit a vertex which is connected to a satisfied literal.) Conversely, if a vertex cover exists, assign each Boolean variable according to whether xt^ (TRUE ) or xf^ (FALSE ) is in M. (By the choice of k, there must be one vertex in each clique which is not in M. This vertex must be adjacent to a vertex in M, hence the clause is satisfied.)

NP-completeness of VERTEX COVER

At least one of each pair (xf^ , xt^ ) must be in the cover At least nj − 1 vertices from each complete graph Gj must be in the cover If the formula is satisfiable, then choose the cover by choosing each literal assigned TRUE plus all but one vertex in each Gj. (Omit a vertex which is connected to a satisfied literal.) Conversely, if a vertex cover exists, assign each Boolean variable according to whether xt^ (TRUE ) or xf^ (FALSE ) is in M. (By the choice of k, there must be one vertex in each clique which is not in M. This vertex must be adjacent to a vertex in M, hence the clause is satisfied.)

NP-completeness of VERTEX COVER

At least one of each pair (xf^ , xt^ ) must be in the cover At least nj − 1 vertices from each complete graph Gj must be in the cover If the formula is satisfiable, then choose the cover by choosing each literal assigned TRUE plus all but one vertex in each Gj. (Omit a vertex which is connected to a satisfied literal.) Conversely, if a vertex cover exists, assign each Boolean variable according to whether xt^ (TRUE ) or xf^ (FALSE ) is in M. (By the choice of k, there must be one vertex in each clique which is not in M. This vertex must be adjacent to a vertex in M, hence the clause is satisfied.)

Hitting Set

HITTING SET

Instance : Collection C of subsets of a set V and a positive integer K. Question: Does S contain a hitting set for C of size K or less, that is, a subset S′^ ⊆ S with |S′| ≤ K such that S′^ contains at least one element form each subset from C?

HITTING SET is in NP (the subset S′^ is the certificate) To show that HITTING SET is NP -complete, restrict it to instances with |c| = 2 for all c ∈ C. What problem do you get then?

3-SATISFIABILITY

To show that 3-SATISFIABILITY is NP -complete we reduce SATISFIABILITY to 3-SATISFIABILITY Replace every clause

C = x 1 ∨ x 2 ∨... ∨ xk

with k > 3 by

C′^ = (x 1 ∨ x 2 ∨ y 1 ) ∧ (¬y 1 ∨ x 3 ∨ y 2 ) ∧... ∧ (¬yk− 3 ∨ xk− 1 ∨ xk )

C is satisfiable iff C′^ is, since at least one of the literals other than the ys must be TRUE.

NP-completeness of SUBSET SUM

Given a formula f with clauses C 1 , C 2 ,... , Ck For each variable x create 2 integers nxt and nxf For each clause Cj of length lj , create lj − 1 integers mj 1 , mj 2 ,... Choose t so that T must contain exactly one of each n pair and at least one from each clause This construction can be carried out in polynomial time

Example Construction

  • x y z a b C 1 C 2 C (x ∨ y ∨ z) ∧ (¬x ∨ ¬a) ∧ (a ∨ b ∨ ¬y ∨ ¬z)
  • nxt =
  • nxf =
  • nyt =
  • nyf =
  • nzt =
  • nzf =
  • nat =
  • naf =
  • nbt =
  • nbf =
  • m 11 =
  • m 12 =
  • m 21 =
  • m 31 =
  • m 32 =
  • m 33 =
  • t =