• Keine Ergebnisse gefunden

Theory of Computer Science D3. Proving NP-Completeness Gabriele R¨oger

N/A
N/A
Protected

Academic year: 2022

Aktie "Theory of Computer Science D3. Proving NP-Completeness Gabriele R¨oger"

Copied!
88
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

D3. Proving NP-Completeness

Gabriele R¨oger

University of Basel

May 10, 2021

(2)

Overview

(3)

Reminder: P and NP

P: class of languages that are decidable in polynomial time by a deterministic Turing machine

NP: class of languages that are decidable in polynomial time by a non-deterministic Turing machine

(4)

Reminder: Polynomial Reductions

Definition (Polynomial Reduction)

LetA⊆Σ andB ⊆Γ be decision problems.

We say thatAcan be polynomially reduced toB,

writtenA≤pB, if there is a functionf : Σ →Γ such that:

f can be computed inpolynomial time by aDTM f reducesA toB

i. e., for allw Σ: w Aifff(w)B f is called apolynomial reductionfromAto B

Transitivity of≤p: IfA≤pB and B≤pC, then A≤pC.

(5)

Reminder: NP-Hardness and NP-Completeness

Definition (NP-Hard, NP-Complete) LetB be a decision problem.

B is called NP-hard ifA≤pB for allproblemsA∈NP.

B is called NP-completeif B∈NP and B is NP-hard.

(6)

Proving NP-Completeness by Reduction

Suppose we know one NP-complete problem

(we will use satisfiability of propositional logic formulas).

With its help, we can then prove quite easily that further problems are NP-complete.

Theorem (Proving NP-Completeness by Reduction) Let A and B be problems such that:

A is NP-hard, and A≤pB.

Then B is also NP-hard.

If furthermore B ∈NP, then B is NP-complete.

(7)

Proving NP-Completeness by Reduction

Suppose we know one NP-complete problem

(we will use satisfiability of propositional logic formulas).

With its help, we can then prove quite easily that further problems are NP-complete.

Theorem (Proving NP-Completeness by Reduction) Let A and B be problems such that:

A is NP-hard, and A≤pB.

Then B is also NP-hard.

If furthermore B ∈NP, then B is NP-complete.

(8)

Proving NP-Completeness by Reduction: Proof

Proof.

First part: We must show X ≤pB for all X ∈NP.

FromX ≤pA(becauseA is NP-hard) andA≤pB

(by prerequisite), this follows due to the transitivity of≤p. Second part: follows directly by definition of NP-completeness.

(9)

Proving NP-Completeness by Reduction: Proof

Proof.

First part: We must show X ≤pB for all X ∈NP.

FromX ≤pA(becauseA is NP-hard) andA≤pB

(by prerequisite), this follows due to the transitivity of≤p. Second part: follows directly by definition of NP-completeness.

(10)

Proving NP-Completeness by Reduction: Proof

Proof.

First part: We must show X ≤pB for all X ∈NP.

FromX ≤pA(becauseA is NP-hard) andA≤pB

(by prerequisite), this follows due to the transitivity of≤p. Second part: follows directly by definition of NP-completeness.

(11)

NP-Complete Problems

There are thousands of known NP-complete problems.

An extensive catalog of NP-complete problems from many areas of computer science is contained in:

Michael R. Garey and David S. Johnson:

Computers and Intractability —

A Guide to the Theory of NP-Completeness W. H. Freeman, 1979.

In the remaining chapters, we get to know some of these problems.

(12)

Overview of the Reductions

SAT

3SAT

Clique

IndSet

VertexCover

DirHamiltonCycle

HamiltonCycle

TSP

SubsetSum

Partition

BinPacking

(13)

What Do We Have to Do?

We want to show the NP-completeness of these 11 problems.

We first show that SATis NP-complete.

Then it is sufficient to show

thatpolynomial reductionsexist for all edges in the figure (and thus all problems are NP-hard)

and that the problems are all in NP.

(It would be sufficient to show membership in NP only for the leaves in the figure. But membership is so easy to show that this would not save any work.)

(14)

Questions

Questions?

(15)

Propositional Logic

(16)

We need to establish NP-completeness of one problem

“from scratch”.

We will use satisfiability of propositional logic formulas.

So what is this?

Let’s briefly cover the basics.

(17)

Overview Propositional Logic Cook-Levin Theorem 3SAT Summary

Propositional Logic: Syntax

Let Abe a set of atomic propositions

→ variables that can be true or false

Everya∈A is a propositional formula over A.

Ifϕis a propositional formula over A, then so is its negation ¬ϕ.

Ifϕ1, . . . , ϕn are propositional formulas over A, then so is the conjunction (ϕ1∧ · · · ∧ϕn).

Ifϕ1, . . . , ϕn are propositional formulas over A, then so is the disjunction (ϕ1∨ · · · ∨ϕn).

¬(X ∧(Y ∨ ¬(Z∧Y))) is a propositional formula over {X,Y,Z}.

(18)

Overview Propositional Logic Cook-Levin Theorem 3SAT Summary

Propositional Logic: Syntax

Let Abe a set of atomic propositions

→ variables that can be true or false

Everya∈A is a propositional formula over A.

Ifϕis a propositional formula over A, then so is its negation ¬ϕ.

Ifϕ1, . . . , ϕn are propositional formulas over A, then so is the conjunction (ϕ1∧ · · · ∧ϕn).

Ifϕ1, . . . , ϕn are propositional formulas over A, then so is the disjunction (ϕ1∨ · · · ∨ϕn).

¬(X ∧(Y ∨ ¬(Z∧Y))) is a propositional formula over {X,Y,Z}.

(19)

Overview Propositional Logic Cook-Levin Theorem 3SAT Summary

Propositional Logic: Syntax

Let Abe a set of atomic propositions

→ variables that can be true or false

Everya∈A is a propositional formula over A.

Ifϕis a propositional formula over A, then so is its negation ¬ϕ.

Ifϕ1, . . . , ϕn are propositional formulas over A, then so is the conjunction (ϕ1∧ · · · ∧ϕn).

Ifϕ1, . . . , ϕn are propositional formulas over A, then so is the disjunction (ϕ1∨ · · · ∨ϕn).

¬(X ∧(Y ∨ ¬(Z∧Y))) is a propositional formula over {X,Y,Z}.

(20)

Overview Propositional Logic Cook-Levin Theorem 3SAT Summary

Propositional Logic: Syntax

Let Abe a set of atomic propositions

→ variables that can be true or false

Everya∈A is a propositional formula over A.

Ifϕis a propositional formula over A, then so is its negation ¬ϕ.

Ifϕ1, . . . , ϕn are propositional formulas over A, then so is theconjunction (ϕ1∧ · · · ∧ϕn).

Ifϕ1, . . . , ϕn are propositional formulas over A, then so is the disjunction (ϕ1∨ · · · ∨ϕn).

¬(X ∧(Y ∨ ¬(Z∧Y))) is a propositional formula over {X,Y,Z}.

(21)

Overview Propositional Logic Cook-Levin Theorem 3SAT Summary

Propositional Logic: Syntax

Let Abe a set of atomic propositions

→ variables that can be true or false

Everya∈A is a propositional formula over A.

Ifϕis a propositional formula over A, then so is its negation ¬ϕ.

Ifϕ1, . . . , ϕn are propositional formulas over A, then so is theconjunction (ϕ1∧ · · · ∧ϕn).

Ifϕ1, . . . , ϕn are propositional formulas over A, then so is thedisjunction (ϕ1∨ · · · ∨ϕn).

¬(X ∧(Y ∨ ¬(Z∧Y))) is a propositional formula over {X,Y,Z}.

(22)

Propositional Logic: Syntax

Let Abe a set of atomic propositions

→ variables that can be true or false

Everya∈A is a propositional formula over A.

Ifϕis a propositional formula over A, then so is its negation ¬ϕ.

Ifϕ1, . . . , ϕn are propositional formulas over A, then so is theconjunction (ϕ1∧ · · · ∧ϕn).

Ifϕ1, . . . , ϕn are propositional formulas over A, then so is thedisjunction (ϕ1∨ · · · ∨ϕn).

Example

¬(X∧(Y ∨ ¬(Z ∧Y))) is a propositional formula over{X,Y,Z}.

(23)

Propositional Logic: Semantics

A truth assignmentfor a set of atomic propositions Ais a functionI :A→ {T,F}.

A formula can be true or false under a given truth assignment.

WriteI |=ϕto express that ϕis true underI.

Atomic variableais true underI iff I(a) =T. Negation¬ϕis true underI iffϕis not:

I |=¬ϕiffI 6|=ϕ

Conjunction (ϕ1∧ · · · ∧ϕn) is true underI iff eachϕi is:

I |= (ϕ1∧ · · · ∧ϕn) iffI |=ϕi for alli∈ {1, . . . ,n}

Disjunction (ϕ1∨ · · · ∨ϕn) is true underI iff someϕi is:

I |= (ϕ1∨ · · · ∨ϕn) iff existsi∈ {1, . . . ,n} such thatI |=ϕi

(24)

Propositional Logic: Example

Consider truth assignmentI ={X 7→F,Y 7→T,Z 7→F}.

Is¬(X ∧(Y ∨ ¬(Z∧Y))) true under I?

(25)

Propositional Logic: Exercise (slido)

Consider truth assignment

I ={X 7→F,Y 7→T,Z 7→F}.

Is(X ∨(¬Z∧Y))true underI?

(26)

More Propositional Logic

(ϕ→ψ) is a short-hand notation for formula (¬ϕ∨ψ).

(ϕ→ψ) is true under variable assignmentI if ϕis not true underI, or

ψis true underI.

If (ϕ→ψ) andϕare true underI then alsoψ must be true underI.

(ϕ↔ψ) is a short-hand notation for formula ((ϕ→ψ)∧(ψ→ϕ))

(ϕ↔ψ) is true under variable assignmentI if both,ϕandψare true under I, or

neitherϕnorψ is true underI.

(27)

More Propositional Logic

(ϕ→ψ) is a short-hand notation for formula (¬ϕ∨ψ).

(ϕ→ψ) is true under variable assignmentI if ϕis not true underI, or

ψis true underI.

If (ϕ→ψ) andϕare true underI then alsoψ must be true underI.

(ϕ↔ψ) is a short-hand notation for formula ((ϕ→ψ)∧(ψ→ϕ))

(ϕ↔ψ) is true under variable assignmentI if both,ϕandψare true under I, or

neitherϕnorψ is true underI.

(28)

More Propositional Logic

(ϕ→ψ) is a short-hand notation for formula (¬ϕ∨ψ).

(ϕ→ψ) is true under variable assignmentI if ϕisnot trueunderI, or

ψis true underI.

If (ϕ→ψ) andϕare true underI then alsoψ must be true underI.

(ϕ↔ψ) is a short-hand notation for formula ((ϕ→ψ)∧(ψ→ϕ))

(ϕ↔ψ) is true under variable assignmentI if both,ϕandψare true under I, or

neitherϕnorψ is true underI.

(29)

More Propositional Logic

(ϕ→ψ) is a short-hand notation for formula (¬ϕ∨ψ).

(ϕ→ψ) is true under variable assignmentI if ϕisnot trueunderI, or

ψis true underI.

If (ϕ→ψ) andϕare true underI then alsoψ must be true underI.

(ϕ↔ψ) is a short-hand notation for formula ((ϕ→ψ)∧(ψ→ϕ))

(ϕ↔ψ) is true under variable assignmentI if both,ϕandψare true under I, or

neitherϕnorψ is true underI.

(30)

More Propositional Logic

(ϕ→ψ) is a short-hand notation for formula (¬ϕ∨ψ).

(ϕ→ψ) is true under variable assignmentI if ϕisnot trueunderI, or

ψis true underI.

If (ϕ→ψ) andϕare true underI then alsoψ must be true underI.

(ϕ↔ψ) is a short-hand notation for formula ((ϕ→ψ)∧(ψ→ϕ))

(ϕ↔ψ) is true under variable assignmentI if both,ϕandψare true under I, or

neitherϕnorψ is true underI.

(31)

More Propositional Logic

(ϕ→ψ) is a short-hand notation for formula (¬ϕ∨ψ).

(ϕ→ψ) is true under variable assignmentI if ϕisnot trueunderI, or

ψis true underI.

If (ϕ→ψ) andϕare true underI then alsoψ must be true underI.

(ϕ↔ψ) is a short-hand notation for formula ((ϕ→ψ)∧(ψ→ϕ))

(ϕ↔ψ) is true under variable assignmentI if both,ϕandψare true under I, or

neitherϕnorψ is true underI.

(32)

More Propositional Logic

(ϕ→ψ) is a short-hand notation for formula (¬ϕ∨ψ).

(ϕ→ψ) is true under variable assignmentI if ϕisnot trueunderI, or

ψis true underI.

If (ϕ→ψ) andϕare true underI then alsoψ must be true underI.

(ϕ↔ψ) is a short-hand notation for formula ((ϕ→ψ)∧(ψ→ϕ))

(ϕ↔ψ) is true under variable assignmentI if both,ϕandψare true under I, or

neitherϕnorψ is true underI.

(33)

More Propositional Logic

(ϕ→ψ) is a short-hand notation for formula (¬ϕ∨ψ).

(ϕ→ψ) is true under variable assignmentI if ϕisnot trueunderI, or

ψis true underI.

If (ϕ→ψ) andϕare true underI then alsoψ must be true underI.

(ϕ↔ψ) is a short-hand notation for formula ((ϕ→ψ)∧(ψ→ϕ))

(ϕ↔ψ) is true under variable assignmentI if both,ϕandψare true under I, or

neitherϕnorψ is true underI.

(34)

More Propositional Logic

(ϕ→ψ) is a short-hand notation for formula (¬ϕ∨ψ).

(ϕ→ψ) is true under variable assignmentI if ϕisnot trueunderI, or

ψis true underI.

If (ϕ→ψ) andϕare true underI then alsoψ must be true underI.

(ϕ↔ψ) is a short-hand notation for formula ((ϕ→ψ)∧(ψ→ϕ))

(ϕ↔ψ) is true under variable assignmentI if both,ϕandψare true under I, or

neitherϕnorψ is true underI.

(35)

Short Notations for Conjunctions and Disjunctions

Short notation for addition:

X

x∈{x1,...,xn}x =x1+x2+· · ·+xn

Analogously (possible because of commutativity of∧ and∨):

^

ϕ∈Xϕ

= (ϕ1∧ϕ2∧ · · · ∧ϕn) _

ϕ∈Xϕ

= (ϕ1∨ϕ2∨ · · · ∨ϕn) forX ={ϕ1, . . . , ϕn}

(36)

SAT Problem

Definition (SAT)

The problemSAT(satisfiability) is defined as follows:

Given: a propositional logic formulaϕ Question: Isϕsatisfiable,

i.e. is there a variable assignmentI such thatI |=ϕ?

(37)

Questions

Questions?

(38)

Cook-Levin Theorem

(39)

SAT is NP-complete

Definition (SAT)

The problemSAT(satisfiability) is defined as follows:

Given: a propositional logic formulaϕ Question: Isϕsatisfiable?

Theorem (Cook, 1971; Levin, 1973) SATis NP-complete.

Proof.

SAT∈NP: guess and check.

SATis NP-hard: somewhat more complicated (to be continued) . . .

(40)

SAT is NP-complete

Definition (SAT)

The problemSAT(satisfiability) is defined as follows:

Given: a propositional logic formulaϕ Question: Isϕsatisfiable?

Theorem (Cook, 1971; Levin, 1973) SATis NP-complete.

Proof.

SAT∈NP: guess and check.

SATis NP-hard: somewhat more complicated (to be continued) . . .

(41)

SAT is NP-complete

Definition (SAT)

The problemSAT(satisfiability) is defined as follows:

Given: a propositional logic formulaϕ Question: Isϕsatisfiable?

Theorem (Cook, 1971; Levin, 1973) SATis NP-complete.

Proof.

SAT∈NP: guess and check.

SATis NP-hard: somewhat more complicated (to be continued) . . .

(42)

NP-hardness of SAT (1)

Proof (continued).

We must show: A≤pSATfor all A∈NP.

LetAbe an arbitrary problem in NP.

We have to find a polynomial reduction ofAto SAT, i. e., a functionf computable in polynomial time

such that for every input wordw over the alphabet of A:

w ∈A iff f(w) is a satisfiable propositional formula. . . .

(43)

NP-hardness of SAT (1)

Proof (continued).

We must show: A≤pSATfor all A∈NP.

LetAbe an arbitrary problem in NP.

We have to find a polynomial reduction ofAto SAT, i. e., a functionf computable in polynomial time

such that for every input wordw over the alphabet of A:

w ∈A iff f(w) is a satisfiable propositional formula. . . .

(44)

NP-hardness of SAT (2)

Proof (continued).

BecauseA∈NP, there is an NTM M and a polynomial p such thatM decides the problemA in timep.

Idea: construct a formula that encodes the possible configurations whichM can reach in time p(|w|) on input w

and that issatisfiable if and only if

an accepting configuration can be reachedin this time. . . .

(45)

NP-hardness of SAT (3)

Proof (continued).

LetM =hQ,Σ,Γ, δ,q0,qaccept,qrejecti be an NTM forA,

and letp be a polynomial bounding the computation time ofM. Without loss of generality,p(n)≥n for all n.

Letw =w1. . .wn∈Σ be the input forM.

We number the tape positions with natural numbers such that the TM head initially is on position 1.

Observation: withinp(n) computation steps the TM head can only reach positions in the setPos={1, . . . ,p(n) + 1}.

Instead of infinitely many tape positions, we now only

need to consider these (polynomially many!) positions. . . .

(46)

NP-hardness of SAT (3)

Proof (continued).

LetM =hQ,Σ,Γ, δ,q0,qaccept,qrejecti be an NTM forA,

and letp be a polynomial bounding the computation time ofM. Without loss of generality,p(n)≥n for all n.

Letw =w1. . .wn∈Σ be the input forM.

We number the tape positions with natural numbers such that the TM head initially is on position 1.

Observation: withinp(n) computation steps the TM head can only reach positions in the setPos={1, . . . ,p(n) + 1}.

Instead of infinitely many tape positions, we now only

need to consider these (polynomially many!) positions. . . .

(47)

NP-hardness of SAT (3)

Proof (continued).

LetM =hQ,Σ,Γ, δ,q0,qaccept,qrejecti be an NTM forA,

and letp be a polynomial bounding the computation time ofM. Without loss of generality,p(n)≥n for all n.

Letw =w1. . .wn∈Σ be the input forM.

We number the tape positions with natural numbers such that the TM head initially is on position 1.

Observation: withinp(n) computation steps the TM head can only reach positions in the setPos={1, . . . ,p(n) + 1}.

Instead of infinitely many tape positions, we now only

need to consider these (polynomially many!) positions. . . .

(48)

NP-hardness of SAT (3)

Proof (continued).

LetM =hQ,Σ,Γ, δ,q0,qaccept,qrejecti be an NTM forA,

and letp be a polynomial bounding the computation time ofM. Without loss of generality,p(n)≥n for all n.

Letw =w1. . .wn∈Σ be the input forM.

We number the tape positions with natural numbers such that the TM head initially is on position 1.

Observation: withinp(n) computation steps the TM head can only reach positions in the setPos={1, . . . ,p(n) + 1}.

Instead of infinitely many tape positions, we now only

need to consider these (polynomially many!) positions. . . .

(49)

NP-hardness of SAT (4)

Proof (continued).

We can encode configurations ofM by specifying:

what the currentstate of M is

on which position in Pos theTM head is located

which symbols from Γ thetape contains at positionsPos can be encoded by propositional variables

To encode a full computation (rather than just one configuration), we need copies of these variables for each computation step.

We only need to consider the computation steps Steps={0,1, . . . ,p(n)} becauseM should accept

withinp(n) steps. . . .

(50)

NP-hardness of SAT (4)

Proof (continued).

We can encode configurations ofM by specifying:

what the currentstate of M is

on which position in Pos theTM head is located

which symbols from Γ thetape contains at positionsPos can be encoded by propositional variables

To encode a fullcomputation(rather than just one configuration), we needcopies of these variables for each computation step.

We only need to consider the computation steps Steps={0,1, . . . ,p(n)} becauseM should accept

withinp(n) steps. . . .

(51)

NP-hardness of SAT (4)

Proof (continued).

We can encode configurations ofM by specifying:

what the currentstate of M is

on which position in Pos theTM head is located

which symbols from Γ thetape contains at positionsPos can be encoded by propositional variables

To encode a fullcomputation(rather than just one configuration), we needcopies of these variables for each computation step.

We only need to consider the computation steps Steps={0,1, . . . ,p(n)} becauseM should accept

withinp(n) steps. . . .

(52)

NP-hardness of SAT (5)

Proof (continued).

Use the following propositional variables in formulaf(w):

statet,q (t ∈Steps,q ∈Q)

encodes the state of the NTM in thet-th configuration headt,i (t ∈Steps,i ∈Pos)

encodes the head position in the t-th configuration tapet,i,a (t∈Steps,i ∈Pos,a∈Γ)

encodes the tape content in thet-th configuration Constructf(w) such that every satisfying interpretation

describes asequence of NTM configurations that begins with the start configuration, reaches an accepting configuration andfollows the NTM rules inδ

. . .

(53)

NP-hardness of SAT (6)

Proof (continued).

Auxiliary formula:

oneof X := _

x∈X

x

!

∧ ¬

 _

x∈X

_

y∈X\{x}

(x∧y)

Auxiliary notation:

The symbol⊥stands for an arbitrary unsatisfiable formula

(e.g., (A∧ ¬A), whereA is an arbitrary proposition). . . .

(54)

NP-hardness of SAT (7)

Proof (continued).

1. describe the configurations of the TM:

Valid:= ^

t∈Steps

oneof {statet,q|q∈Q} ∧

oneof {headt,i |i ∈Pos} ∧

^

i∈Pos

oneof {tapet,i,a|a∈Γ}

. . .

(55)

NP-hardness of SAT (8)

Proof (continued).

2. begin in the start configuration Init:=state0,q0∧head0,1

n

^

i=1

tape0,i,wi ∧ ^

i∈Pos\{1,...,n}

tape0,i,

. . .

(56)

NP-hardness of SAT (9)

Proof (continued).

3. reach an accepting configuration

Accept:= _

t∈Steps

statet,qaccept

. . .

(57)

NP-hardness of SAT (10)

Proof (continued).

4. follow the rules inδ:

Trans:= ^

t∈Steps

statet,qaccept∨statet,qreject∨ _

R∈δ

Rulet,R

!

where. . . .

(58)

NP-hardness of SAT (11)

Proof (continued).

4. follow the rules inδ (continued):

Rulet,hhq,ai,hq0,a0,Dii:=

statet,q∧statet+1,q0

^

i∈Pos

headt,i → tapet,i,a∧headt+1,i+D∧tapet+1,i,a0

^

i∈Pos

^

a00∈Γ

¬headt,i∧tapet,i,a00

→tapet+1,i,a00

For i+D, interpret i+ R i+ 1, i+ L max{1,i−1}.

special case: tape andhead variables with a tape index i+D outside of Pos are replaced by⊥; likewise all variables

with a time index outside of Steps. . . .

(59)

NP-hardness of SAT (12)

Proof (continued).

Putting the pieces together:

Setf(w) :=Valid∧Init∧Accept∧Trans.

f(w) can be constructed in time polynomial in |w|.

w ∈A iffM acceptsw in p(|w|) steps w ∈A ifff(w) is satisfiable

w ∈A ifff(w)∈SAT A≤pSAT

SinceA∈NP was arbitrary, this is true for every A∈NP.

HenceSATis NP-hard and thus also NP-complete.

(60)

NP-hardness of SAT (12)

Proof (continued).

Putting the pieces together:

Setf(w) :=Valid∧Init∧Accept∧Trans.

f(w) can be constructed in time polynomial in |w|.

w ∈A iffM acceptsw in p(|w|) steps w ∈A ifff(w) is satisfiable

w ∈A ifff(w)∈SAT A≤pSAT

SinceA∈NP was arbitrary, this is true for every A∈NP.

HenceSATis NP-hard and thus also NP-complete.

(61)

NP-hardness of SAT (12)

Proof (continued).

Putting the pieces together:

Setf(w) :=Valid∧Init∧Accept∧Trans.

f(w) can be constructed in time polynomial in |w|.

w ∈A iffM acceptsw in p(|w|) steps w ∈A ifff(w) is satisfiable

w ∈A ifff(w)∈SAT A≤pSAT

SinceA∈NP was arbitrary, this is true for every A∈NP.

HenceSATis NP-hard and thus also NP-complete.

(62)

NP-hardness of SAT (12)

Proof (continued).

Putting the pieces together:

Setf(w) :=Valid∧Init∧Accept∧Trans.

f(w) can be constructed in time polynomial in |w|.

w ∈A iffM acceptsw in p(|w|) steps w ∈A ifff(w) is satisfiable

w ∈A ifff(w)∈SAT A≤pSAT

SinceA∈NP was arbitrary, this is true for every A∈NP.

HenceSATis NP-hard and thus also NP-complete.

(63)

Questions

Questions?

(64)

3SAT

(65)

More Propositional Logic: Conjunctive Normal Form

A literalis an atomic proposition X or its negation¬X. A clause is a disjunction of literals,

e.g. (X∨ ¬Y ∨Z)

A formula in conjunctive normal form is a conjunction of clauses,

e.g. ((X ∨ ¬Y ∨Z)∧(¬X ∨ ¬Z)∧(X ∨Y))

(66)

More Propositional Logic: Conjunctive Normal Form

A literalis an atomic proposition X or its negation¬X. A clauseis a disjunction of literals,

e.g. (X∨ ¬Y ∨Z)

A formula in conjunctive normal form is a conjunction of clauses,

e.g. ((X ∨ ¬Y ∨Z)∧(¬X ∨ ¬Z)∧(X ∨Y))

(67)

More Propositional Logic: Conjunctive Normal Form

A literalis an atomic proposition X or its negation¬X. A clauseis a disjunction of literals,

e.g. (X∨ ¬Y ∨Z)

A formula inconjunctive normal form is a conjunction of clauses,

e.g. ((X ∨ ¬Y ∨Z)∧(¬X ∨ ¬Z)∧(X ∨Y))

(68)

Exercise (slido)

Which of the following formulas are in conjunctive normal form?

((X ∧ ¬Y ∧Z)∨(¬X ∧ ¬Z)) (X∨ ¬Y ∨Z)

((¬X ∨ ¬Z)∧ ¬(X ∨Y)) ((¬Y ∨X)∧(Y ∨ ¬Z))

(69)

SAT ≤

p

3SAT

SAT

3SAT

Clique

IndSet

VertexCover

DirHamiltonCycle

HamiltonCycle

TSP

SubsetSum

Partition

BinPacking

(70)

SAT and 3SAT

Definition (Reminder: SAT)

The problemSAT(satisfiability) is defined as follows:

Given: a propositional logic formulaϕ Question: Isϕsatisfiable?

Definition (3SAT)

The problem3SATis defined as follows:

Given: a propositional logic formulaϕ in conjunctive normal form with at most three literals per clause

Question: Isϕsatisfiable?

(71)

3SAT is NP-Complete (1)

Theorem (3SATis NP-Complete) 3SATis NP-complete.

(72)

3SAT is NP-Complete (2)

Proof.

3SAT∈NP: guess and check.

3SATis NP-hard: We showSAT≤p3SAT.

Let ϕbe the given input for SAT. LetSub(ϕ) denote the set of subformulas of ϕ, includingϕitself.

For all ψ∈Sub(ϕ), we introduce a new proposition Xψ. For each new proposition Xψ, define the following auxiliary formula χψ:

Ifψ=Afor an atomA: χψ = (XψA) Ifψ=¬ψ0: χψ = (Xψ↔ ¬Xψ0)

Ifψ= (ψ0ψ00): χψ= (Xψ (Xψ0Xψ00)) Ifψ= (ψ0ψ00): χψ= (Xψ (Xψ0Xψ00))

. . .

(73)

3SAT is NP-Complete (2)

Proof.

3SAT∈NP: guess and check.

3SATis NP-hard: We showSAT≤p3SAT.

Let ϕbe the given input for SAT. LetSub(ϕ) denote the set of subformulas of ϕ, includingϕitself.

For all ψ∈Sub(ϕ), we introduce a new proposition Xψ. For each new proposition Xψ, define the following auxiliary formula χψ:

Ifψ=Afor an atomA: χψ = (XψA) Ifψ=¬ψ0: χψ = (Xψ↔ ¬Xψ0)

Ifψ= (ψ0ψ00): χψ= (Xψ (Xψ0Xψ00)) Ifψ= (ψ0ψ00): χψ= (Xψ (Xψ0Xψ00))

. . .

(74)

3SAT is NP-Complete (2)

Proof.

3SAT∈NP: guess and check.

3SATis NP-hard: We showSAT≤p3SAT.

Let ϕbe the given input for SAT. LetSub(ϕ) denote the set of subformulas of ϕ, includingϕitself.

For all ψ∈Sub(ϕ), we introduce a new proposition Xψ. For each new proposition Xψ, define the following auxiliary formula χψ:

Ifψ=Afor an atomA: χψ =(XψA) Ifψ=¬ψ0: χψ =(Xψ↔ ¬Xψ0)

Ifψ= (ψ0ψ00): χψ=(Xψ (Xψ0Xψ00)) Ifψ= (ψ0ψ00): χψ=(Xψ (Xψ0Xψ00))

. . .

(75)

3SAT is NP-Complete (3)

Proof (continued).

Consider the conjunction of all these auxiliary formulas, χall :=V

ψ∈Sub(ϕ)χψ.

Every variable assignment I for the original variables can be extended to a variable assignmentI0

under which χall is true in exactly one way:

for eachψ∈Sub(ϕ), setI0(Xψ) =T iff I |=ψ.

It follows thatϕ is satisfiable iff (χall∧Xϕ) is satisfiable.

This formula can be computed in linear time.

It can also be converted to 3-CNF in linear time because it is the conjunction of constant-size parts involving at most three variables each.

(Each part can be converted to 3-CNF independently.) Hence, this describes a polynomial-time reduction.

(76)

3SAT is NP-Complete (3)

Proof (continued).

Consider the conjunction of all these auxiliary formulas, χall :=V

ψ∈Sub(ϕ)χψ.

Every variable assignment I for the original variables can be extended to a variable assignmentI0

under which χall is true in exactly one way:

for eachψ∈Sub(ϕ), setI0(Xψ) =T iff I |=ψ.

It follows thatϕ is satisfiable iff (χall∧Xϕ) is satisfiable.

This formula can be computed in linear time.

It can also be converted to 3-CNF in linear time because it is the conjunction of constant-size parts involving at most three variables each.

(Each part can be converted to 3-CNF independently.) Hence, this describes a polynomial-time reduction.

(77)

3SAT is NP-Complete (3)

Proof (continued).

Consider the conjunction of all these auxiliary formulas, χall :=V

ψ∈Sub(ϕ)χψ.

Every variable assignment I for the original variables can be extended to a variable assignmentI0

under which χall is true in exactly one way:

for eachψ∈Sub(ϕ), setI0(Xψ) =T iff I |=ψ.

It follows thatϕ is satisfiable iff (χall∧Xϕ) is satisfiable.

This formula can be computed in linear time.

It can also be converted to 3-CNF in linear time because it is the conjunction of constant-size parts involving at most three variables each.

(Each part can be converted to 3-CNF independently.) Hence, this describes a polynomial-time reduction.

(78)

3SAT is NP-Complete (3)

Proof (continued).

Consider the conjunction of all these auxiliary formulas, χall :=V

ψ∈Sub(ϕ)χψ.

Every variable assignment I for the original variables can be extended to a variable assignmentI0

under which χall is true in exactly one way:

for eachψ∈Sub(ϕ), setI0(Xψ) =T iff I |=ψ.

It follows thatϕ is satisfiable iff (χall∧Xϕ) is satisfiable.

This formula can be computed in linear time.

It can also be converted to 3-CNF in linear time because it is the conjunction of constant-size parts involving at most three variables each.

(Each part can be converted to 3-CNF independently.) Hence, this describes a polynomial-time reduction.

(79)

3SAT is NP-Complete (3)

Proof (continued).

Consider the conjunction of all these auxiliary formulas, χall :=V

ψ∈Sub(ϕ)χψ.

Every variable assignment I for the original variables can be extended to a variable assignmentI0

under which χall is true in exactly one way:

for eachψ∈Sub(ϕ), setI0(Xψ) =T iff I |=ψ.

It follows thatϕ is satisfiable iff (χall∧Xϕ) is satisfiable.

This formula can be computed in linear time.

It can also be converted to 3-CNF in linear time because it is the conjunction of constant-size parts involving at most three variables each.

(Each part can be converted to 3-CNF independently.) Hence, this describes a polynomial-time reduction.

(80)

3SAT is NP-Complete (3)

Proof (continued).

Consider the conjunction of all these auxiliary formulas, χall :=V

ψ∈Sub(ϕ)χψ.

Every variable assignment I for the original variables can be extended to a variable assignmentI0

under which χall is true in exactly one way:

for eachψ∈Sub(ϕ), setI0(Xψ) =T iff I |=ψ.

It follows thatϕ is satisfiable iff (χall∧Xϕ) is satisfiable.

This formula can be computed in linear time.

It can also be converted to 3-CNF in linear time because it is the conjunction of constant-size parts involving at most three variables each.

(Each part can be converted to 3-CNF independently.) Hence, this describes a polynomial-time reduction.

(81)

Restricted 3SAT

Note: 3SAT remains NP-complete if we also require that every clause containsexactly three literals and a clause may not contain the same literal twice Idea:

remove duplicated literals from each clause.

add new variables: X,Y,Z

add new clauses: (X∨Y ∨Z), (X∨Y ∨ ¬Z), (X ∨ ¬Y ∨Z), (¬X∨Y ∨Z), (X ∨ ¬Y ∨ ¬Z), (¬X ∨Y ∨ ¬Z),

(¬X∨ ¬Y ∨Z)

satisfied if and only if X,Y,Z are all true fill up clauses with fewer than three literals with ¬X and if necessary additionally with¬Y

(82)

Restricted 3SAT

Note: 3SAT remains NP-complete if we also require that every clause containsexactly three literals and a clause may not contain the same literal twice Idea:

remove duplicated literals from each clause.

add new variables: X,Y,Z

add new clauses: (X∨Y ∨Z), (X∨Y ∨ ¬Z), (X ∨ ¬Y ∨Z), (¬X∨Y ∨Z), (X ∨ ¬Y ∨ ¬Z), (¬X ∨Y ∨ ¬Z),

(¬X∨ ¬Y ∨Z)

satisfied if and only if X,Y,Z are all true fill up clauses with fewer than three literals with ¬X and if necessary additionally with¬Y

(83)

Restricted 3SAT

Note: 3SAT remains NP-complete if we also require that every clause containsexactly three literals and a clause may not contain the same literal twice Idea:

remove duplicated literals from each clause.

add new variables: X,Y,Z

add new clauses: (X∨Y ∨Z), (X∨Y ∨ ¬Z), (X ∨ ¬Y ∨Z), (¬X∨Y ∨Z), (X ∨ ¬Y ∨ ¬Z), (¬X ∨Y ∨ ¬Z),

(¬X∨ ¬Y ∨Z)

satisfied if and only if X,Y,Z are all true fill up clauses with fewer than three literals with ¬X and if necessary additionally with¬Y

(84)

Restricted 3SAT

Note: 3SAT remains NP-complete if we also require that every clause containsexactly three literals and a clause may not contain the same literal twice Idea:

remove duplicated literals from each clause.

add new variables: X,Y,Z

add new clauses: (X∨Y ∨Z), (X∨Y ∨ ¬Z), (X ∨ ¬Y ∨Z), (¬X∨Y ∨Z), (X ∨ ¬Y ∨ ¬Z), (¬X ∨Y ∨ ¬Z),

(¬X∨ ¬Y ∨Z)

satisfied if and only if X,Y,Z are all true fill up clauses with fewer than three literals with ¬X and if necessary additionally with¬Y

(85)

Restricted 3SAT

Note: 3SAT remains NP-complete if we also require that every clause containsexactly three literals and a clause may not contain the same literal twice Idea:

remove duplicated literals from each clause.

add new variables: X,Y,Z

add new clauses: (X∨Y ∨Z), (X∨Y ∨ ¬Z), (X ∨ ¬Y ∨Z), (¬X∨Y ∨Z), (X ∨ ¬Y ∨ ¬Z), (¬X ∨Y ∨ ¬Z),

(¬X∨ ¬Y ∨Z)

satisfied if and only if X,Y,Z are all true fill up clauses with fewer than three literals with ¬X and if necessary additionally with¬Y

(86)

Questions

Questions?

(87)

Summary

(88)

Summary

Thousands of important problems are NP-complete.

The satisfiability problem of propositional logic (SAT) is NP-complete.

Proof idea forNP-hardness:

Every problem in NP can be solved by an NTM in polynomial timep(|w|) for inputw.

Given a wordw, construct a propositional logic formulaϕ that encodes the computation steps of the NTM on inputw.

Constructϕso that it is satisfiable if and only if there is an accepting computation of lengthp(|w|).

Usually (as seen for3SAT), the easiest way to show that another problem is NP-complete is to

show that it is in NP with a guess-and-check algorithm, and polynomially reduce a known NP-complete to it.

Referenzen

ÄHNLICHE DOKUMENTE

I For the undecidability of the halting problem, we will use an analogous argument, only with Turing machines instead of code and termination instead of return values... The

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

I Can they solve problems efficiently (in polynomial time) which deterministic algorithms cannot solve efficiently. I This is the

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

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

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