• Keine Ergebnisse gefunden

D4.1GraphProblemsD4.2RoutingProblems D4.1GraphProblems TheoryofComputerScience TheoryofComputerScience 3SAT ≤ Clique

N/A
N/A
Protected

Academic year: 2022

Aktie "D4.1GraphProblemsD4.2RoutingProblems D4.1GraphProblems TheoryofComputerScience TheoryofComputerScience 3SAT ≤ Clique"

Copied!
10
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Theory of Computer Science

D4. Some NP-Complete Problems, Part I

Gabriele R¨ oger

University of Basel

May 18, 2020

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 1 / 40

Theory of Computer Science

May 18, 2020 — D4. Some NP-Complete Problems, Part I

D4.1 Graph Problems

D4.2 Routing Problems

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 2 / 40

D4. Some NP-Complete Problems, Part I Graph Problems

D4.1 Graph Problems

D4. Some NP-Complete Problems, Part I Graph Problems

3SAT ≤ p Clique

SAT

3SAT

Clique

IndSet

DirHamiltonCycle

HamiltonCycle

SubsetSum

Partition

(2)

Clique

Definition ( Clique )

The problem Clique is defined as follows:

Given: undirected graph G = hV , E i, number K ∈ N 0

Question: Does G have a clique of size at least K , i. e., a set of vertices C ⊆ V with |C | ≥ K

and {u, v } ∈ E for all u, v ∈ C with u 6= v ? German: Clique

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 5 / 40

Cliques: Exercise (slido)

How many nodes has the largest clique of this graph?

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 6 / 40

D4. Some NP-Complete Problems, Part I Graph Problems

Clique is NP-Complete (1)

Theorem ( Clique is NP-Complete) Clique is NP-complete.

D4. Some NP-Complete Problems, Part I Graph Problems

Clique is NP-Complete (2)

Proof.

Clique ∈ NP: guess and check.

Clique is NP-hard: We show 3SAT ≤ p Clique .

I We are given a 3-CNF formula ϕ, and we may assume that each clause has exactly three literals.

I In polynomial time, we must construct

a graph G = hV , E i and a number K such that:

G has a clique of size at least K iff ϕ is satisfiable.

construction of V , E, K on the following slides.

. . .

(3)

Clique is NP-Complete (3)

Proof (continued).

Let m be the number of clauses in ϕ.

Let ` ij the j -th literal in clause i.

Define V , E , K as follows:

I V = {hi , j i | 1 ≤ i ≤ m, 1 ≤ j ≤ 3}

a vertex for every literal of every clause

I E contains edge between hi, j i and hi 0 , j 0 i if and only if I i 6= i

0

belong to different clauses, and

I `

ij

and `

i0j0

are not complementary literals I K = m

obviously polynomially computable

to show: reduction property . . .

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 9 / 40

Clique is NP-Complete (4)

Proof (continued).

(⇒): If ϕ is satisfiable, then hV , E i has clique of size at least K : I Given a satisfying variable assignment choose a vertex

corresponding to a satisfied literal in each clause.

I The chosen K vertices are all connected with each other and hence form a clique of size K .

. . .

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 10 / 40

D4. Some NP-Complete Problems, Part I Graph Problems

Clique is NP-Complete (5)

Proof (continued).

(⇐): If hV , E i has a clique of size at least K , then ϕ is satisfiable:

I Consider a given clique C of size at least K .

I The vertices in C must all correspond to different clauses (vertices in the same clause are not connected by edges).

exactly one vertex per clause is included in C

I Two vertices in C never correspond to complementary literals X and ¬X (due to the way we defined the edges).

I If a vertex corresp. to X was chosen, map X to T (true).

I If a vertex corresp. to ¬X was chosen, map X to F (false).

I If neither was chosen, arbitrarily map X to T or F.

D4. Some NP-Complete Problems, Part I Graph Problems

Clique ≤ p IndSet

SAT

3SAT

Clique

IndSet

DirHamiltonCycle

HamiltonCycle

SubsetSum

Partition

(4)

IndSet

Definition ( IndSet )

The problem IndSet is defined as follows:

Given: undirected graph G = hV , E i, number K ∈ N 0

Question: Does G have an independent set of size at least K , i. e., a set of vertices I ⊆ V with |I | ≥ K

and {u, v } ∈ / E for all u, v ∈ I with u 6= v ? German: unabh¨ angige Menge

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 13 / 40

Independent Set: Exercise (slido)

Does this graph have an independent set of size 3?

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 14 / 40

D4. Some NP-Complete Problems, Part I Graph Problems

IndSet is NP-Complete (1)

Theorem ( IndSet is NP-Complete) IndSet is NP-complete.

Proof.

IndSet ∈ NP: guess and check. . . .

D4. Some NP-Complete Problems, Part I Graph Problems

IndSet is NP-Complete (2)

Proof (continued).

IndSet is NP-hard: We show Clique ≤ p IndSet . We describe a polynomial reduction f .

Let hG , K i with G = hV , E i be the given input for Clique . Then f (hG , K i) is the IndSet instance hG , K i, where G := hV , Ei and E := {{u, v } ⊆ V | u 6= v , {u, v } ∈ / E }.

(This graph G is called the complement graph of G .)

Clearly f can be computed in polynomial time. . . .

(5)

IndSet is NP-Complete (3)

Proof (continued).

We have:

hhV , Ei, K i ∈ Clique

iff there exists a set V 0 ⊆ V with |V 0 | ≥ K and {u, v } ∈ E for all u, v ∈ V 0 with u 6= v iff there exists a set V 0 ⊆ V with |V 0 | ≥ K

and {u, v } ∈ / E for all u, v ∈ V 0 with u 6= v iff hhV , Ei, K i ∈ IndSet

iff f (hhV , Ei, K i) ∈ IndSet

and hence f is a reduction.

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 17 / 40

IndSet ≤ p VertexCover

SAT

3SAT

Clique

IndSet

VertexCover

DirHamiltonCycle

HamiltonCycle

TSP

SubsetSum

Partition

BinPacking

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 18 / 40

D4. Some NP-Complete Problems, Part I Graph Problems

VertexCover

Definition ( VertexCover )

The problem VertexCover is defined as follows:

Given: undirected graph G = hV , E i, number K ∈ N 0

Question: Does G have a vertex cover of size at most K , i. e., a set of vertices C ⊆ V with |C | ≤ K and {u, v } ∩ C 6= ∅ for all {u, v } ∈ E ?

German: Knoten¨ uberdeckung

D4. Some NP-Complete Problems, Part I Graph Problems

Vertex Cover: Exercise (slido)

(6)

VertexCover is NP-Complete (1)

Theorem ( VertexCover is NP-Complete) VertexCover is NP-complete.

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 21 / 40

VertexCover is NP-Complete (2)

Proof.

VertexCover ∈ NP: guess and check.

VertexCover is NP-hard:

We show IndSet ≤ p VertexCover . We describe a polynomial reduction f .

Let hG , K i with G = hV , E i be the given input for IndSet . Then f (hG , K i) := hG , |V | − K i.

This can clearly be computed in polynomial time. . . .

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 22 / 40

D4. Some NP-Complete Problems, Part I Graph Problems

VertexCover is NP-Complete (3)

Proof (continued).

For vertex set V 0 ⊆ V , we write V 0 for its complement V \ V 0 . Observation: a set of vertices is a vertex cover

iff its complement is an independent set.

We thus have:

hhV , E i, K i ∈ IndSet

iff hV , E i has an independent set I with |I| ≥ K iff hV , E i has a vertex cover C with |C | ≥ K iff hV , E i has a vertex cover C with |C | ≤ |V | − K iff hhV , E i, |V | − K i ∈ VertexCover

iff f (hhV , E i, K i) ∈ VertexCover

and hence f is a reduction.

D4. Some NP-Complete Problems, Part I Routing Problems

D4.2 Routing Problems

(7)

3SAT ≤ p DirHamiltonCycle

SAT

3SAT

Clique

IndSet

VertexCover

DirHamiltonCycle

HamiltonCycle

TSP

SubsetSum

Partition

BinPacking

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 25 / 40

DirHamiltonCycle is NP-Complete (1)

Definition (Reminder: DirHamiltonCycle )

The problem DirHamiltonCycle is defined as follows:

Given: directed graph G = hV , E i

Question: Does G contain a Hamilton cycle?

Theorem

DirHamiltonCycle is NP-complete.

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 26 / 40

D4. Some NP-Complete Problems, Part I Routing Problems

DirHamiltonCycle is NP-Complete (2)

Proof.

DirHamiltonCycle ∈ NP: guess and check.

DirHamiltonCycle is NP-hard:

We show 3SAT ≤ p DirHamiltonCycle .

I We are given a 3-CNF formula ϕ where each clause contains exactly three literals and no clause contains duplicated literals.

I We must, in polynomial time, construct a directed graph G = hV , Ei such that:

G contains a Hamilton cycle iff ϕ is satisfiable.

I construction of hV , Ei on the following slides

D4. Some NP-Complete Problems, Part I Routing Problems

DirHamiltonCycle is NP-Complete (3)

Proof (continued).

I Let X 1 , . . . , X n be the atomic propositions in ϕ.

I Let c 1 , . . . , c m be the clauses of ϕ with c i = (` i 1 ∨ ` i 2 ∨ ` i 3 ).

I Construct a graph with 6m + n vertices (described on the following slides).

. . .

(8)

DirHamiltonCycle is NP-Complete (4)

Proof (continued).

I For every variable X i , add vertex x i with 2 incoming and 2 outgoing edges:

x1 x2 . . . xn

I For every clause c j , add the subgraph C j with 6 vertices:

a

b

c

A

B

C

I We describe later how to connect these parts.

. . .

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 29 / 40

DirHamiltonCycle is NP-Complete (5)

Proof (continued).

Let π be a Hamilton cycle of the total graph.

I Whenever π enters subgraph C j from one of its “entrances”, it must leave via the corresponding “exit”:

(a −→ A, b −→ B, c −→ C ).

Otherwise, π cannot be a Hamilton cycle.

I Hamilton cycles can behave in the following ways with regard to C j :

I π passes through C

j

once (from any entrance) I π passes through C

j

twice (from any two entrances) I π passes through C

j

three times (once from every entrance)

. . .

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 30 / 40

D4. Some NP-Complete Problems, Part I Routing Problems

DirHamiltonCycle is NP-Complete (6)

Proof (continued).

Connect the “open ends” in the graph as follows:

I Identify entrances/exits of the clause subgraph C j with the three literals in clause c j .

I One exit of x i is positive, the other one is negative.

I For the positive exit, determine the clauses in which the positive literal X i occurs:

I Connect the positive exit of x

i

with the X

i

-entrance of the first such clause graph.

I Connect the X

i

-exit of this clause graph with the X

i

-entrance of the second such clause graph, and so on.

I Connect the X

i

-exit of the last such clause graph with the positive entrance of x

i+1

(or x

1

if i = n).

I analogously for the negative exit of x i and the literal ¬X i . . .

D4. Some NP-Complete Problems, Part I Routing Problems

DirHamiltonCycle is NP-Complete (7)

Proof (continued).

The construction is polynomial and is a reduction:

(⇒): construct a Hamilton cycle from a satisfying assignment I Given a satisfying assignment I, construct a Hamilton cycle

that leaves x i through the positive exit if I(X i ) is true and by the negative exit if I(X i ) is false.

I Afterwards, we visit all C j -subgraphs for clauses that are satisfied by this literal.

I In total, we visit each C j -subgraph 1–3 times.

. . .

(9)

DirHamiltonCycle is NP-Complete (8)

Proof (continued).

(⇐): construct a satisfying assignment from a Hamilton cycle I A Hamilton cycle visits every vertex x i

and leaves it by the positive or negative exit.

I Map X i to true or false depending on which exit is used to leave x i .

I Because the cycle must traverse each C j -subgraph at least once (otherwise it is not a Hamilton cycle), this results in a satisfying assignment. (Details omitted.)

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 33 / 40

DirHamiltonCycle ≤ p HamiltonCycle

SAT

3SAT

Clique

IndSet

VertexCover

DirHamiltonCycle

HamiltonCycle

TSP

SubsetSum

Partition

BinPacking

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 34 / 40

D4. Some NP-Complete Problems, Part I Routing Problems

HamiltonCycle is NP-Complete (1)

Definition (Reminder: HamiltonCycle )

The problem HamiltonCycle is defined as follows:

Given: undirected graph G = hV , E i

Question: Does G contain a Hamilton cycle?

Theorem

HamiltonCycle is NP-complete.

D4. Some NP-Complete Problems, Part I Routing Problems

HamiltonCycle is NP-Complete (2)

Proof sketch.

HamiltonCycle ∈ NP: guess and check.

HamiltonCycle is NP-hard: We show DirHamiltonCycle ≤ p HamiltonCycle . Basic building block of the reduction:

v

= ⇒

v1 v2 v3

(10)

HamiltonCycle ≤ p TSP

SAT

3SAT

Clique

IndSet

VertexCover

DirHamiltonCycle

HamiltonCycle

TSP

SubsetSum

Partition

BinPacking

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 37 / 40

TSP is NP-Complete (1)

Definition (Reminder: TSP )

TSP (traveling salesperson problem) is the following decision problem:

I Given: finite set S 6= ∅ of cities, symmetric cost function cost : S × S → N 0 , cost bound K ∈ N 0

I Question: Is there a tour with total cost at most K , i. e., a permutation hs 1 , . . . , s n i of the cities with

P n−1

i=1 cost(s i , s i+1 ) + cost(s n , s 1 ) ≤ K ? German: Problem der/des Handlungsreisenden Theorem

TSP is NP-complete.

Gabriele R¨oger (University of Basel) Theory of Computer Science May 18, 2020 38 / 40

D4. Some NP-Complete Problems, Part I Routing Problems

TSP is NP-Complete (2)

Proof.

TSP ∈ NP: guess and check.

TSP is NP-hard: We showed HamiltonCycle ≤ p TSP in Chapter D2.

D4. Some NP-Complete Problems, Part I Summary

Summary

I In this chapter we showed NP-completeness of I three classical graph problems:

Clique , IndSet , VertexCover I three classical routing problems:

DirHamiltonCycle , HamiltonCycle , TSP

Referenzen

ÄHNLICHE DOKUMENTE

for 2.: identical to (1), only that M B only recognizes B and therefore the simulation does not necessarily terminate if y 6∈ B. Since y 6∈ B iff x 6∈ A, the procedure still

for 2.: identical to (1), only that M B only recognizes B and therefore the simulation does not necessarily terminate if y 6∈ B. Since y 6∈ B iff x 6∈ A, the procedure still

We number the tape positions with natural numbers such that the TM head initially is on position 1. Observation: within p(n) computation steps the TM head can only reach positions

Gabriele R¨ oger (University of Basel) Theory of Computer Science May 10, 2021 10 /

Clique , IndSet , VertexCover three classical routing problems:. DirHamiltonCycle , HamiltonCycle

Does this graph have a vertex cover of size 4?.. VertexCover is

By using one or both of the padding numbers for each clause digit, all clause digits can be brought to their target value of 4, solving the SubsetSum instance. I For

An oracle machine is like a Turing machine that has access to an oracle which can solve some decision problem in constant timeA. Example