np-completeness - university of texas at san antoniobylander/cs5633/notes/np-completeness.pdf ·...

32
CS 5633 Analysis of Algorithms Chapter 32: Slide – 1 NP-Completeness Problems and Instances Polynomial Time Verification NP-completeness and Reducibility NP-completeness Proofs NP-complete Problems

Upload: others

Post on 22-Apr-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

CS 5633 Analysis of Algorithms Chapter 32: Slide – 1

NP-Completeness

Problems and InstancesPolynomial Time VerificationNP-completeness and ReducibilityNP-completeness ProofsNP-complete Problems

Page 2: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

Introduction

Introduction

⊲ intro 1

intro 2

intro 3

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 2

Mostly, we have studied problems withpolynomial-time algorithms:running time is O(nk), for input size n and someconstant k.

Many problems have no poly-time-alg, e.g.,halting problem.For a third set of problems, it is unknown whetherthey have poly-time-algs or not.

This third set includes the class of NP-complete

problems.

Page 3: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

Examples of P and NPC Problems

Introduction

intro 1

⊲ intro 2

intro 3

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 3

P = class of problems solvable in polynomial-time.NPC = class of NP-complete problems.NP = class of NP problems (includes P and NPC).

Single-source shortest paths is in P.Finding the longest simple path is in NPC.a

Finding a Euler tour (each edge once) is in P.Finding a hamiltonian cycle (each vertex once) isin NPC.a

Finding a solution to 2-CNF formulas is in P.Finding a solution to 3-CNF formulas is in NPC.a

aTechnically, this problem is NP-hard.

Page 4: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

Reductions

Introduction

intro 1

intro 2

⊲ intro 3

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 4

A decision problem is a problem with yes/noanswers.

We can show that decision problem A is in P ifthere is a poly-time-alg that reduces A to adecision problem B which is known to be in P.

That is, each instance α ∈ A is converted to aninstance β ∈ B such that B’s algorithm deliversthe answer to α.

Page 5: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

Problems and Instances

Introduction

The Complexity

Class P

⊲ P 1

P 2

P 3

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 5

An abstract problem is a relation from instances

to solutions.

E.g., integer addition: instance 2 + 2, solution 4.E.g., equations: instance x2 = 9, sols. 3 and −3.

A decision problem has solutions = {yes,no}.Abstract problems have related decision problems.Integer addition DP: instance 2 + 2 ≥ 3, sol. yes.Equation DP: instance x2 = 9, x ≥ 4, solution no.

An encoding maps instances to (binary) strings.E.g., a graph can be an adjacency list or matrix.Encodings map abstract to concrete problems.

Page 6: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

The P Complexity Class

Introduction

The Complexity

Class P

P 1

⊲ P 2

P 3

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 6

A problem Q is polynomial-time solvable ifthere exists an algorithm A and a constant ksuch that A solves all instances in O(nk),where n is the length of the encoded instance.

The language of a decision problem is the set ofinstances with yes solutions.

The polynomial complexity class P is defined:

P = {L : L is a language decided bya polynomial-time algorithm}

Page 7: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

Example P Problems

Introduction

The Complexity

Class P

P 1

P 2

⊲ P 3

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 7

PATH = { 〈G, u, v, k〉 :G = (V,E) is an undirected graph,u, v ∈ V ,k ≥ 0 is an integer, andthere exists a path from u to v in G

consisting of k edges or less.}

MEDIAN = { 〈S,m〉 :S is a set of integers,m is an integer, andm ≤ the median of S}

Page 8: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

Hamiltonian Cycles

Introduction

The Complexity

Class P

The Complexity

Class NP

⊲ verification 1

verification 2

verification 3

Polynomial

Reducibility

The Complexity

Class NPC

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 8

A hamiltonian cycle of an undirected graph is asimple cycle that contains all vertices.

HAM-CYCLE = {〈G〉 : G has a hamiltonian cycle}

Page 9: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

Verification Algorithms

Introduction

The Complexity

Class P

The Complexity

Class NP

verification 1

⊲ verification 2

verification 3

Polynomial

Reducibility

The Complexity

Class NPC

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 9

No P algorithm is known for HAM-CYCLE.

But given a path p in a graph G, a P algorithmcan verify whether p is a hamiltonian cycle.

A verification algorithm A(x, y) has two args.:the input string x and the certificate y.The language verified by A(x, y) is:

L = {x : there exists y s.t. A(x, y) = yes}

For HAM-CYCLE, x would be a graph, and thecertificate y would be a path.

Page 10: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

The NP Complexity Class

Introduction

The Complexity

Class P

The Complexity

Class NP

verification 1

verification 2

⊲ verification 3

Polynomial

Reducibility

The Complexity

Class NPC

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 10

NP is the class of problem with P verificationalgorithms with poly-size certificates.

L ∈ NP iff there exists a P algorithm A(x, y) anda constant c such that:

L = {x : there exists a y such that|y| is O(|x|c), and A(x, y) = yes}

HAM-CYCLE ∈ NP because if G ∈ HAM-CYCLE,then the certificate is the hamiltonian path p.

Consider:SAT = {〈φ〉 : φ is a satisfiable boolean formula}COMPOSITE = {〈n〉 : n is a composite integer}

Page 11: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

Reducibility (Informal)

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

⊲ reducibility 1

reducibility 2

reducibility 3

reducibility 4

reducibility 5

reducibility 6

The Complexity

Class NPC

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 11

A problem Q can be reduced to a problem Q′ ifeach instance x of Q can be transformed to aninstance x′ of Q′ such that the solution to x′ canbe transformed back to a solution for x.

Finding the median reduces to sorting.Topological sort reduces to depth-first search.Difference constraints reduces to shortest-paths.

In a larger sense, all programming is finding a wayto “reduce” (or “transform”) the problem to besolved to the API of a programming language.

Page 12: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

Reducibility (Formal)

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

reducibility 1

⊲ reducibility 2

reducibility 3

reducibility 4

reducibility 5

reducibility 6

The Complexity

Class NPC

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 12

A language L1 is polynomial-time reducible to L2

(L1 ≤P L2) if a polynomial-time function f

satisfies x ∈ L1 if and only if f(x) ∈ L2.

Page 13: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

Reducibility Examples

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

reducibility 1

reducibility 2

⊲ reducibility 3

reducibility 4

reducibility 5

reducibility 6

The Complexity

Class NPC

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 13

EVEN = {〈n〉 : n is an even number}ODD = {〈n〉 : n is an odd number}EVEN ≤P ODD (and vice versa)

MEDIAN = {〈S, n〉 : n ≤ S’s median}ORDER-STATISTIC ={〈S, n, i〉 : n ≤ S’s ith order statistic}MEDIAN ≤P ORDER-STATISTIC

CONNECTED ={〈G〉 : G is a connected, undirected graph}STRONGLY-CONNECTED ={〈G〉 : G is a strongly connected, directed graph}CONNECTED ≤P STRONGLY-CONNECTED

Page 14: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

Reducibility Properties

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

reducibility 1

reducibility 2

reducibility 3

⊲ reducibility 4

reducibility 5

reducibility 6

The Complexity

Class NPC

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 14

If L1 ≤P L2 and L2 ∈ P, then L1 ∈ P.If L1 ≤P L2 and L1 6∈ P, then L2 6∈ P.

Proof:Let F be a O(nk) reduction alg. for L1 ≤P L2.Let A2 be a O(nl) algorithm for L2.We can define an algorithm A1 for L1 by

A1(x) = A2(F (x))

F is O(nk) implies the size of F (x) is O(|x|k).A2 is O(nl) implies A2 is O(|x|kl) on an input ofsize O(|x|k).It follows that A1 ∈ P because A1 is O(nkl).

Page 15: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

Another Reducibility Example

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

reducibility 1

reducibility 2

reducibility 3

reducibility 4

⊲ reducibility 5

reducibility 6

The Complexity

Class NPC

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 15

HAMPATH = {〈G, u, v〉 : there is a simple pathfrom u to v including all vertices}

SIMPLE = {〈G, u, v, l〉 : there is a simple pathfrom u to v with length l}

HAMPATH ≤P SIMPLE byf(G, u, v) = 〈G, u, v, |G.V | − 1〉

Now need to show x = 〈G, u, v〉 ∈ HAMPATH ifand only if x′ = 〈G, u, v, |G.V | − 1〉 ∈ SIMPLE.

If x ∈ HAMPATH, then G has a simple pathincluding all vertices, which has length |G.V | − 1.

If x′ ∈ SIMPLE, then a simple path of length|G.V | − 1 must include all of G’s vertices.

Page 16: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

And Another Reducibility Example

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

reducibility 1

reducibility 2

reducibility 3

reducibility 4

reducibility 5

⊲ reducibility 6

The Complexity

Class NPC

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 16

HAM-CYCLE = {〈G〉 : G has a hamiltonian cycle}HAMPATH = {〈G, u, v〉 : there is a simple path

from u to v including all vertices}HAM-CYCLE ≤P HAMPATH byf(G) = 〈G′, u, u′〉 where G′ is constructedby copying G and duplicating any vertex u.

Now need to show x = 〈G〉 ∈ HAM-CYCLE if andonly if x′ = 〈G, u, u′〉 ∈ HAMPATH.

If x ∈ HAM-CYCLE, then G′ has a simple pathfrom u: use G′ ham. cycle, but end with u′.

If x′ ∈ HAMPATH, then G has a ham. cycle: startfrom u, use G′ simple path, but end with u.

Page 17: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

Elements for Defining NPC

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

⊲ NPC 1

NPC 2

NPC 3

NPC 4

NPC 5

NPC 6

NPC 7

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 17

Recall NP and ≤P.

L ∈ NP iff there exists a P algorithm A(x, y) anda constant c such that:

L = {x : there exists a certificate y such that|y| is O(|x|c), and A(x, y) = yes}

A language L1 is polynomial-time reducible to L2

(L1 ≤P L2) if a polynomial-time function f

satisfies x ∈ L1 if and only if f(x) ∈ L2.

Page 18: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

The Definition of NP-Complete

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC 1

⊲ NPC 2

NPC 3

NPC 4

NPC 5

NPC 6

NPC 7

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 18

L is NP-hard if L′ ≤P L for every L′ ∈ NP.L ∈ NPC if L ∈ NP and L is NP-hard.

If L ∈ NPC and L ∈ P, then NP = P.No known L is both NPC and P.

CIRCUIT-SAT = set of satisfiable boolean circuits

CIRCUIT-SAT ∈ NPC because it is in NP and allNP problems ≤P CIRCUIT-SAT.

Page 19: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

CIRCUIT-SAT

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC 1

NPC 2

⊲ NPC 3

NPC 4

NPC 5

NPC 6

NPC 7

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 19

Sketch of reduction of any L ∈ NP toCIRCUIT-SAT.

Simulate a computer cycle of L’s verificationalgorithm by a boolean circuit plus booleaninputs/outputs.

Simulate a sequence of cycles by a sequence ofcircuits.

A poly-time verification algorithm and a poly-sizecertificate implies a poly-number of cycles, whichimplies a poly-size circuit.

Page 20: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

NP-Completeness Proofs and SAT

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC 1

NPC 2

NPC 3

⊲ NPC 4

NPC 5

NPC 6

NPC 7

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 20

To show that L is NP-complete (L ∈ NPC)1. Show L ∈ NP.2. Show L′ ≤P L for a known languageL′ ∈ NPC.

SAT = set of satisfiable Boolean formulas

1. SAT ∈ NP because if φ ∈ SAT, then thecertificate is the assignment making φ true.

2. CIRCUIT-SAT ≤P SAT as follows.Map each gate’s output to a variable.Map each gate to a formula.AND all the formulas.

Page 21: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

Illustration for SAT Reduction

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC 1

NPC 2

NPC 3

NPC 4

⊲ NPC 5

NPC 6

NPC 7

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 21

x5 ↔ (x1 ∨ x2) =(x5 → (x1 ∨ x2)) ∧ ((x1 ∨ x2) → x5) =(¬x5 ∨ x1 ∨ x2) ∧ (¬(x1 ∨ x2) ∨ x5)

Page 22: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

3-CNF-SAT

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC 1

NPC 2

NPC 3

NPC 4

NPC 5

⊲ NPC 6

NPC 7

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 22

3-CNF-SAT = satisfiable 3-CNF formula,where each formula is a conjunction of clauses,where each clause is a disjunction of 3 literals,where each literal is a variable or a negated var.

1. 3-CNF-SAT ∈ NP because if φ ∈ 3-CNF-SAT,the certificate is the assignment making φ true.

2. SAT ≤P 3-CNF-SAT as follows.Map each operator output to a variable.Create a dummy input for each negation.Each operator has 2 inputs and 1 output.Use truth tables to map each op. to clauses.AND all the clauses.

Page 23: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

Illustration for 3-CNF-SAT Reduction

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC 1

NPC 2

NPC 3

NPC 4

NPC 5

NPC 6

⊲ NPC 7

NPC Proofs

CS 5633 Analysis of Algorithms Chapter 32: Slide – 23

y1 ↔ (y2 ∧ ¬x2) =(y1 → (y2 ∧ ¬x2)) ∧ ((y2 ∧ ¬x2) → y1) =(¬y1 ∨ (y2 ∧ ¬x2)) ∧ (¬(y2 ∧ ¬x2) ∨ y1) =(¬y1 ∨ y2) ∧ (¬y1 ∨ ¬x2) ∧ (¬y2 ∨ x2 ∨ y1)

Page 24: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

The Sequence of Reductions

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC Proofs

⊲ NPC Proofs

clique 1

clique 2

vertex cover 1

vertex cover 3

vertex cover 3

subset sum 1

subset sum 2

subset sum 3

CS 5633 Analysis of Algorithms Chapter 32: Slide – 24

Page 25: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

CLIQUE

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC Proofs

NPC Proofs

⊲ clique 1

clique 2

vertex cover 1

vertex cover 3

vertex cover 3

subset sum 1

subset sum 2

subset sum 3

CS 5633 Analysis of Algorithms Chapter 32: Slide – 25

A clique of an undirected graph is a subset ofvertices with edges between all pairs.

CLIQUE = {〈G, k〉 : G has a clique of size k}

1. CLIQUE ∈ NP because if x ∈ CLIQUE, thenthe clique of k vertices is a certificate.

2. 3-CNF-SAT ≤P CLIQUE as follows.Map m clauses to 3m vertices,one per literal per clause.If a literal in one clause does not conflict witha literal in another clause, add an edge.Satisfying assignment iff clique of size m.

Page 26: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

3-CNF-SAT ≤P CLIQUE Illustration

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC Proofs

NPC Proofs

clique 1

⊲ clique 2

vertex cover 1

vertex cover 3

vertex cover 3

subset sum 1

subset sum 2

subset sum 3

CS 5633 Analysis of Algorithms Chapter 32: Slide – 26

x1

x2

x3

x1 x2 x3

x1 x2 x3

x1

x2

x3

x2

x1

x3

x2

x1

x3

x2x1 x3

x2x1 x3

Page 27: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

VERTEX COVER

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC Proofs

NPC Proofs

clique 1

clique 2

⊲ vertex cover 1

vertex cover 3

vertex cover 3

subset sum 1

subset sum 2

subset sum 3

CS 5633 Analysis of Algorithms Chapter 32: Slide – 27

A vertex cover of an undirected graph is a subsetof vertices that covers all the edges. If edge (u, v),then either u or v (or both) are in vertex cover.

VERTEX-COVER ={〈G, k〉 : G has a vertex cover of size k}

1. VERTEX-COVER ∈ NP because if x ∈ V.-C.,then the vertex cover of size k is a certificate.

2. CLIQUE ≤P VERTEX-COVER.Map clique instance x = 〈G, k〉 tovertex cover instance x′ = 〈G, |G.V | − k〉.G is the complement of G.C is a clique of G iff G.V − C is a v.c. of G.

Page 28: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

CLIQUE ≤P VERTEX-COVER Illustration

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC Proofs

NPC Proofs

clique 1

clique 2

vertex cover 1

⊲ vertex cover 3

vertex cover 3

subset sum 1

subset sum 2

subset sum 3

CS 5633 Analysis of Algorithms Chapter 32: Slide – 28

u v

wz

y x

u v

wz

y x

G G

Page 29: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

CLIQUE ≤P VERTEX-COVER Proof

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC Proofs

NPC Proofs

clique 1

clique 2

vertex cover 1

vertex cover 3

⊲ vertex cover 3

subset sum 1

subset sum 2

subset sum 3

CS 5633 Analysis of Algorithms Chapter 32: Slide – 29

Proof of reduction:

If C is a clique of G of size k,then G has no edge in C × C,so G.V − C is a vertex cover of Gof size |G.V | − k.

If G has no clique of size k,then for any set of vertices C of size k,C is not a clique,which implies G has an edge in C × C,so G.V − C is not a vertex cover of G.

Page 30: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

SUBSET SUM

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC Proofs

NPC Proofs

clique 1

clique 2

vertex cover 1

vertex cover 3

vertex cover 3

⊲ subset sum 1

subset sum 2

subset sum 3

CS 5633 Analysis of Algorithms Chapter 32: Slide – 30

Subset set is the problem of finding a subset ofnumbers that sum to a given value.

SUBSET-SUM ={〈S, t〉 : A subset S ′ ⊆ S satisfies t = Σs∈S′ s}

1. SUBSET-SUM ∈ NP becauseif x ∈ SUBSET-SUM,then the subset of numbers that sum to t

is a certificate.

Page 31: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

3-CNF-SAT ≤P SUBSET-SUM

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC Proofs

NPC Proofs

clique 1

clique 2

vertex cover 1

vertex cover 3

vertex cover 3

subset sum 1

⊲ subset sum 2

subset sum 3

CS 5633 Analysis of Algorithms Chapter 32: Slide – 31

2. 3-SAT-CNF ≤P SUBSET-SUM.

Map each literal to a decimal numberwith v + c digits, where v = number of variablesand c = number of clauses.

For i ≤ v, digit i = 1 if literal is xi or ¬xi.Digit v + j = 1 if literal is in clause j.All other digits are 0.

We want a satifying assignment if and only ifsome subset sums to 111 . . . 333 . . .

Need additional numbers to ensure clausecolumns can sum to 3.

Page 32: NP-Completeness - University of Texas at San Antoniobylander/cs5633/notes/np-completeness.pdf · 2015-04-20 · Examples of P and NPC Problems Introduction intro 1⊲ intro 2 intro

3-CNF-SAT ≤P SUBSET-SUM Illustration

Introduction

The Complexity

Class P

The Complexity

Class NP

Polynomial

Reducibility

The Complexity

Class NPC

NPC Proofs

NPC Proofs

clique 1

clique 2

vertex cover 1

vertex cover 3

vertex cover 3

subset sum 1

subset sum 2

⊲ subset sum 3

CS 5633 Analysis of Algorithms Chapter 32: Slide – 32

(x1 ∨ x2 ∨ x3) ∨ (¬x1 ∨ x2 ∨ x3) ∨(¬x1 ∨ ¬x2 ∨ ¬x3) ∨ (x1 ∨ ¬x2 ∨ ¬x3)

x1 1 0 0 1 0 0 1¬x1 1 0 0 0 1 1 0x2 0 1 0 1 1 0 0

¬x2 0 1 0 0 0 1 1x3 0 0 1 1 1 0 0

¬x3 0 0 1 0 0 1 1

s1 0 0 0 1 0 0 0s′1

0 0 0 1 0 0 0s2 0 0 0 0 1 0 0s′2

0 0 0 0 1 0 0s3 0 0 0 0 0 1 0s′3

0 0 0 0 0 1 0s4 0 0 0 0 0 0 1s′4

0 0 0 0 0 0 1Use t = 1113333.