CSCE 411 Lecture 32

From Notes
Jump to navigation Jump to search
Lecture Slides

« previous | Monday, November 12, 2012 | next »


NP-Completeness

  1. L∈NP
  2. L′≤pL∀L′∈NP

Suppose L is NP-complete

  1. If there is a poly time algorithm for L, then P=NP
  2. If there is no poly time algorithm for L, then P≠NP

Showing NP-Completeness

Direct approach:

  1. Show L∈NP
  2. Show that every other language in NP is polinomially reducible to L.

Better approach:

  1. Show L∈NP
  2. Choose appropriate known NP complete language L′
  3. Show L′≤pL

Works by transitivity.

First NP-Complete Problem

Satisfiability problem (SAT): given a boolean function, is there a set of true and false inputs that will return true?

First, some vocab:

Boolean variables
take on values T or F (e.g. x,y)
Literal
a variable or a negation or a variable (e.g. x,¬x)
Clause
disjunction (OR) of several literals x∨¬y∨z∨¬w
Conjunctive Normal Form (CNF) formula
is a conjunction (AND) of several clauses (e.g. (¬x∨y)∧(¬z∨¬w∨x)


Is x∨¬y satisfiable? (Yes, x=T, y=F

A formula that has n variables has 2n possible inputs.

SAT is NP-Complete

SAT is in NP: it's hard to find a solution, but when given a solution, checking it is easy. Just plug it into the function.

Show every language in NP is polynomially reducible to SAT.

key idea: each NP language is solved by some nondeterministic Turing machine in polynomial time.

Given a description of a poly time TM, construct in poly time, a CNF formula that simulates the computation of the turing machine.

3SAT

A special case of SAT: each clause contains exactly 3 literals

3SAT is in NP because SAT is in NP

Is 3SAT NP-complete? Regular structure may be exploited to obtain poly algorithm. (e.g. 2SAT has poly time algorithm)

  1. Use same truth-assignment algorithm as SAT to verify solution
  2. Use SAT as NP-complete problem
  3. reduce 3SAT problem to SAT problem in poly time such that SAT problem is satisfiable iff 3SAT is satisfiable

Reduction

Reduction requires some simple boolean algebra:

Given CNF formula of m clauses over set of vars U, replace each clause with a set of 3-clauses, and may use some extra variables.

Let ci=z1∧…∧zk.

Case k=1: use 2 extra variables yi1 and yi2 to replace ci with 4 clauses:

  • (z1∨yi1∨yi2)
  • (z1∨¬yi1∨yi2)
  • (z1∨yi1∨¬yi2)
  • (z1∨¬yi1∨¬yi2)

Case k=2: use 1 extra variable yi1 to replace ci with 2 clauses:

  • (z1∨z2∨¬yi1)
  • (z1∨z2∨yi1)

Case k=3: no work necessary

Case k>3: use k−2 variables yi1,…yik−3 to replace ci with k−2 clauses:

  • (z1∨z2∨yi1)
  • (¬yi1∨z3∨yi2)
  • (¬yi2∨z3∨yi3)
  • ...
  • (¬yik−4∨zk−2∨yik−3)
  • (¬yik−3∨zk−1∨zk)

Is Reduction Poly Time?

Running time of reduction is proportional to the size of SAT problem.

Size of new formula is constant factor larger than original formula:

  • 1 literal → 4 clauses
  • 2 literals → 2 clauses
  • 3 literals → 1 clause
  • 4+ literals → k−2 clauses


Note: Minesweeper is NP-complete: given a configuration of numbers, can we find placement of mines that is coherent with those numbers?