51
UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels Spring, 2009 Lecture 6 Lecture 6 Tuesday, 3/24/09 Tuesday, 3/24/09 NP-Completeness NP-Completeness

UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels Spring, 2009

  • Upload
    devon

  • View
    47

  • Download
    0

Embed Size (px)

DESCRIPTION

UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels Spring, 2009. Lecture 6 Tuesday, 3/24/09 NP-Completeness . Overview. Graham Videotape Review: Reduction to Establish Lower Bounds Basics Practicing Some Reductions How to Treat NP- Hard or Complete Problems. - PowerPoint PPT Presentation

Citation preview

UMass Lowell Computer Science 91.503 Analysis of Algorithms

Prof. Karen Daniels Spring, 2009

Lecture 6Lecture 6Tuesday, 3/24/09Tuesday, 3/24/09

NP-Completeness NP-Completeness

Overview

Graham VideotapeGraham Videotape Review: Reduction to Establish Lower BoundsReview: Reduction to Establish Lower Bounds BasicsBasics Practicing Some ReductionsPracticing Some Reductions How to Treat NP- Hard or Complete ProblemsHow to Treat NP- Hard or Complete Problems

Resources

• Recommended:Recommended:• Computers & IntractabilityComputers & Intractability

• by Garey & Johnsonby Garey & Johnson• W.H.FreemanW.H.Freeman• 19901990• ISBN 0716710455.ISBN 0716710455.

• For further study…For further study…• Computational Complexity: A Conceptual PerspectiveComputational Complexity: A Conceptual Perspective

• by Oded Goldreichby Oded Goldreich• 20082008• ISBN 978-0-521-88473-0ISBN 978-0-521-88473-0

Motivation

Why do we care??

When faced with a problem in practice, need to When faced with a problem in practice, need to know whether or not one can expect produce a know whether or not one can expect produce a “fast” algorithm (i.e. O(n“fast” algorithm (i.e. O(nkk)) to solve it)) to solve it

““Intractable” problems occur frequently in Intractable” problems occur frequently in practicepractice

Surface differences between tractable and Surface differences between tractable and intractable problems are often hard to seeintractable problems are often hard to see e.g. MST solvable in polynomial time but e.g. MST solvable in polynomial time but

Dominating Set intractableDominating Set intractable

Dominating Set

source: Garey & Johnsonsource: Garey & Johnson

Industrial MotivationSupporting Apparel Manufacturing

Ordered Ordered ContainmentContainment

Geometric RestrictionGeometric Restriction

Distance-Based Distance-Based SubdivisionSubdivision

Maximum Maximum RectangleRectangle

Limited GapsLimited Gaps

Minimal Minimal EnclosureEnclosure

Column-Based LayoutColumn-Based LayoutTwo-Phase LayoutTwo-Phase Layout

Lattice Lattice PackingPacking

Maximal CoverMaximal Cover

ContainmentContainmentNP-completeNP-complete

Covering Research Example: Translational 2D Covering [CCCG’01, CCCG’03 conference papers]

Q3Q1 Q2

Sample P and Q

P1

P2

Translated Q Covers P

P1

Q1

Q2

Q3

P2Translational 2D Polygon CoveringTranslational 2D Polygon Covering

Input: Input: Covering polygons Covering polygons QQ = { = {QQ11, , QQ2 2 , ... , , ... , QQmm}} Target polygons (or point-sets) Target polygons (or point-sets) PP = { = {PP11, , PP2 2 , ... , , ... , PPnn}}

Output:Output: Translations Translations = { = { 11, , 2 2 , ... , , ... , mm} such that} such that

mjj j

QP

1

)(

STATICSTATIC

NP-COMPLETENP-COMPLETE

Covering Problem Taxonomy

covering

P: finite point sets

geometric covering

2D translational covering

non-geometric covering

P: shapes

cover )()( iijj QoverlapmayQ partition

:

)()( iijj QoverlapcannotQ

VERTEX-COVER, SET-COVER, EDGE-COVER, VLSI logic minimization, facility location

Polynomial-time algorithms for triangulation and some tilings

Q: convex Q: nonconvex BOX-COVER

-Thin coverings of the plane with congruent convex shapes-Translational covering of a convex set by a sequence of convex shapes-Translational covering of nonconvex set with nonidentical covering shapes

-NP-hard/complete polygon problems-polynomial-time results for restricted orthogonal polygon covering and horizontally convex polygons-approximation algorithms for boundary, corner covers of orthogonal polygons

. . . .

. . . . . .

covering

mjj j

QP

1

)(

decomposition:

mjj j

QP

1

)(

Q: identical

. . .

1D interval covered by annuli

Reduction to Establish Lower Bound

Tightening a Lower Bound for Tightening a Lower Bound for Maximum-Area Axis-Parallel Maximum-Area Axis-Parallel

Rectangle ProblemRectangle Problem from from (n) to (n) to (nlgn)(nlgn)

Approach

Go around lower bound brick wall by:Go around lower bound brick wall by: examining examining strongstrong lower bounds for some similar lower bounds for some similar

problemsproblems transforming a similar problem to the rectangle transforming a similar problem to the rectangle

problemproblem[this process is similar to what we do when we prove problems NP-complete][this process is similar to what we do when we prove problems NP-complete]

nn11 22nnnn55

worst-case boundsworst-case bounds on problemon problem

nn22n logn log22 n n

Lower Bound of (n log n) by Transforming a (seemingly unrelated) Problem

MAX-GAP MAX-GAP instanceinstance: given : given nn real numbers { x real numbers { x11, x, x22, ... x, ... xn n } find the } find the maximum difference between 2 consecutive numbers in the maximum difference between 2 consecutive numbers in the sortedsorted list. list.

O(n) time transformationO(n) time transformationspecialized specialized polygonpolygon

xx22xx44 xx33 xx11

Rectangle Rectangle area is a area is a solution to the solution to the MAX-GAP MAX-GAP instanceinstance

Rectangle algorithm must take as least as much time as MAX-GAP.Rectangle algorithm must take as least as much time as MAX-GAP.MAX-GAP is known to be in MAX-GAP is known to be in (n log n).(n log n).

Rectangle algorithm must take Rectangle algorithm must take (n log n) time(n log n) timefor specialized polygons. for specialized polygons.

[[Transforming yet another different problem yields bound for unspecialized polygons.]Transforming yet another different problem yields bound for unspecialized polygons.]

NP-Completeness

Chapter 34Chapter 34

Basic Concepts

Polynomial Time & Problem FormalizationPolynomial Time & Problem FormalizationPolynomial-Time VerificationPolynomial-Time Verification

NP-Completeness & ReducibilityNP-Completeness & ReducibilityNP-Completeness ProofsNP-Completeness Proofs

Expanding List of Hard Problems via ReductionExpanding List of Hard Problems via Reduction

Polynomial Time & Problem Formalization

Formalize notions of abstract and concrete decision Formalize notions of abstract and concrete decision problemsproblems

Encoding a problemEncoding a problem Define class of polynomial-time solvable decision Define class of polynomial-time solvable decision

problemsproblems Define complexity classDefine complexity class Express relationship between decision problems and Express relationship between decision problems and

algorithms that solve them using framework of algorithms that solve them using framework of formal language theoryformal language theory

Polynomial Time & Problem Formalization (continued)

Solvable in Polynomial TimeSolvable in Polynomial Time i.e. i.e. (n(nkk) for some positive constant k) for some positive constant k Tractable: k is typically small (e.g. 1, 2, 3)Tractable: k is typically small (e.g. 1, 2, 3) Typically holds across sequential computation modelsTypically holds across sequential computation models Closure properties (chaining/composition)Closure properties (chaining/composition)

Abstract Problem:Abstract Problem: Binary relation on set of problem instances & solutionsBinary relation on set of problem instances & solutions

Decision ProblemDecision Problem: yes/no answer: yes/no answer impose bound on optimization problem to recastimpose bound on optimization problem to recast e.g. Dominating Sete.g. Dominating Set

Dominating Set

source: Garey & Johnsonsource: Garey & Johnson

Polynomial Time & Problem Formalization (continued)

EncodingEncoding of set of set SS of abstract objects is mapping of abstract objects is mapping ee from from SS to set to set of binary stringsof binary strings

Concrete ProblemConcrete Problem: instance set is set of binary strings: instance set is set of binary strings Concrete Problem is Concrete Problem is Polynomial-Time SolvablePolynomial-Time Solvable if there exists if there exists

an algorithm to solve it in time an algorithm to solve it in time (n(nkk) for some positive constant ) for some positive constant kk

Complexity Class Complexity Class PP = set of polynomial-time solvable = set of polynomial-time solvable concreteconcrete decision problems decision problems

Given abstract decision problem Given abstract decision problem QQ that maps instance set that maps instance set II to to {0,1}{0,1} can induce a concrete decision problem can induce a concrete decision problem e(Q)e(Q)

If solution to abstract-problem instanceIf solution to abstract-problem instance then solution to concrete-problem instance is alsothen solution to concrete-problem instance is also Q(i) Q(i)

}1,0{: Ie

}1,0{: Ie}1,0{)( iQisIi

Polynomial Time & Problem Formalization (continued)

is is polynomial-time computablepolynomial-time computable if there exists a if there exists a polynomial-time algorithm polynomial-time algorithm AA that, given any input , produces that, given any input , produces f(x)f(x) as output.as output.

For set For set II of problem instances, encodings are of problem instances, encodings are polynomially relatedpolynomially related if there if there exist 2 polynomial-time computable functions exist 2 polynomial-time computable functions ff1212, , ff2121 such that such that

If 2 encodings If 2 encodings ee11, , ee22 of abstract problem are polynomially related, then of abstract problem are polynomially related, then polynomial-time solvability of problem is encoding-independent:polynomial-time solvability of problem is encoding-independent:

}1,0{}1,0{:f

GoalGoal: Extend definition of polynomial-time solvability from : Extend definition of polynomial-time solvability from concrete to abstract using encodings as bridgeconcrete to abstract using encodings as bridge

}1,0{x

Lemma 34.1Lemma 34.1: : Let Let QQ be an be an abstractabstract decision problem on an instance set decision problem on an instance set II and let and let ee11, , ee22 be polynomially related encodings on be polynomially related encodings on II. .

Then, Then, PQePQe )()( 21

)())(()())((, 12212112 ieiefandieiefIi

Polynomial Time & Problem Formalization (continued)

Formal Language FrameworkFormal Language Framework Alphabet Alphabet is finite set of symbols: is finite set of symbols: Language Language LL over over is any set of strings consisting of symbols is any set of strings consisting of symbols

from from Set of instances for decision problem Set of instances for decision problem QQ is is View View QQ as language as language LL over over = {0,1} = {0,1} Express relation between decision problems and algorithmsExpress relation between decision problems and algorithms

Algorithm Algorithm AA acceptsaccepts string if, given input string if, given input xx, output , output A(x)A(x) is 1 is 1 Language Language accepted byaccepted by AA is set of strings is set of strings AA accepts accepts

}1,0{x

}1,0{ for}1)(:{ xQxL

}1)(:}1,0{{ xAxL

}1,0{for *}1,0{

Polynomial Time & Problem Formalization (continued)

Formal Language Framework Formal Language Framework (continued)(continued) Language Language LL is is decided bydecided by algorithm algorithm AA if every binary if every binary

string in string in LL is accepted by is accepted by AA and every binary string not in and every binary string not in LL is rejected by is rejected by AA

Language Language LL is is accepted in polynomial time byaccepted in polynomial time by algorithm algorithm AA if it is accepted by if it is accepted by AA and if exists constant and if exists constant kk such that, such that, for any length-for any length-nn string , string , AA accepts accepts xx in time O( in time O(nnkk))

Language Language LL is is decided in polynomial time bydecided in polynomial time by algorithm algorithm AA if exists constant if exists constant kk such that, for any length- such that, for any length-nn string string , , AA correctly decides in time O( correctly decides in time O(nnkk) if ) if

*}1,0{xLx

Lx

Polynomial Time & Problem Formalization (continued)

Formal Language Framework Formal Language Framework (continued)(continued) Complexity Class is a set of languages whose membership is Complexity Class is a set of languages whose membership is

determined by a complexity measure (i.e. running time) of determined by a complexity measure (i.e. running time) of algorithm that determines whether a given string belongs to a algorithm that determines whether a given string belongs to a language.language.

We already defined: Complexity Class P = set of polynomial-time We already defined: Complexity Class P = set of polynomial-time solvable concrete decision problemssolvable concrete decision problems

Language Framework gives other definitions:Language Framework gives other definitions:

PP = { = { : there exists an algorithm : there exists an algorithm AA that that

decides decides LL in polynomial time} in polynomial time}

= { = { LL : : LL is accepted by a polynomial-time algorithm} is accepted by a polynomial-time algorithm}

*}1,0{L

Polynomial-Time Verification

Examine algorithms that “verify” Examine algorithms that “verify” membership in languagesmembership in languages

Define class of decision problems whose Define class of decision problems whose solutions can be verified in polynomial timesolutions can be verified in polynomial time

Polynomial-Time Verification (continued)

Verification AlgorithmsVerification Algorithms algorithm algorithm AA verifies language verifies language LL if for any string if for any string

certificate certificate yy that that AA can use to prove can use to prove that that

also, for any string also, for any string certificate certificate yy that that AA can use can use to prove thatto prove that

language verified by verification algorithm language verified by verification algorithm AA is is}1),(*}1,0{:}*1,0{{ yxAthatsuchyxL

LxLx

LxLx

Polynomial-Time Verification (continued)

The Complexity Class NPThe Complexity Class NP languages that can be verified by a polynomial-time languages that can be verified by a polynomial-time

algorithm algorithm AA

AA verifiesverifies language language LL in polynomial timein polynomial time

The Complexity Class co-NPThe Complexity Class co-NP set of languages set of languages LL such that such that

}1),()|(|||:}*1,0{{

yxAthatsuchxOythatsuchyecertificatxL c

NPL

Polynomial-Time Verification (continued)

coNPNP coNPNP

coNPNP

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

PP

PP PP

34.3

coNPNP

coNPNP

NP-Completeness & Reducibility

Polynomial-Time ReducibilityPolynomial-Time Reducibility Define complexity class of NP-complete Define complexity class of NP-complete

problemsproblems Relationships among complexity classesRelationships among complexity classes Circuit satisfiability as an NP-complete Circuit satisfiability as an NP-complete

problemproblem

NP-Completeness & Reducibility (continued)

QQ can be reduced to can be reduced to Q’Q’ if any instance of if any instance of QQ can be “easily can be “easily rephrased as an instance of rephrased as an instance of Q’Q’, the solution to which provides , the solution to which provides solution to instance of solution to instance of QQ

LL11 is polynomial-time reducible to is polynomial-time reducible to LL22 : : if exists polynomial-time computable functionif exists polynomial-time computable function

source: 91.503 source: 91.503 textbook Cormen et al.textbook Cormen et al.

*}1,0{ *}1,0{

21 LL P

34.4

21 )( LxfLx

*}1,0{*}1,0{}*1,0{: xthatsuchf

NP-Completeness & Reducibility (continued)

2121 *}1,0{, LLthatsuchlanguagesareLLIf P

PLPLThen 12

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

34.5 34.3

1, LxNO

1, LxYES

2)(, LxfNO )(xf

2)(, LxfYES

NP-Completeness & Reducibility (continued)

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

Language is NP-complete ifLanguage is NP-complete if

NPL NPLLL P ','andand

*}1,0{Lwithout this condition, without this condition, language is only NP-hardlanguage is only NP-hard

NPNPset of all NP-set of all NP-complete complete languageslanguages

popular popular theoretical theoretical computer computer science viewscience view

TheoremTheorem: : - If any NP-complete problem is polynomial-time solvable, then P=NP. - If any NP-complete problem is polynomial-time solvable, then P=NP.

- Equivalently, if any problem in NP is not polynomial-time solvable, then no - Equivalently, if any problem in NP is not polynomial-time solvable, then no NP-complete problem is polynomial-time solvable. NP-complete problem is polynomial-time solvable.

Expanding List of Hard Problems via Reduction

Relationships among some NP-complete problemsRelationships among some NP-complete problems

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.source: Garey & Johnsonsource: Garey & Johnson

Circuit-SATCircuit-SAT

Need to show that starting problem is in NPNeed to show that starting problem is in NP

First NP-complete problem: First NP-complete problem: Boolean Formula Satisfiability (Cook ’71)Boolean Formula Satisfiability (Cook ’71)

NP-Completeness & Reducibility (continued): Circuit Satisfiability

Satisfying AssignmentSatisfying Assignment: : truth assignment truth assignment inducing output = 1inducing output = 1

GOALGOAL: Show Circuit : Show Circuit Satisfiability is Satisfiability is NP-NP-completecomplete

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

Boolean Boolean Combinational Combinational Gate Types: Gate Types: AND, NOT, ORAND, NOT, OR

single circuit output

circuit inputs

Language DefLanguage Def: CIRCUIT-SAT = : CIRCUIT-SAT =

{<C>:C is a satisfiable boolean {<C>:C is a satisfiable boolean combinational circuit.}combinational circuit.}

34.8

NP-Completeness & Reducibility (continued) Circuit Satisfiability

CIRCUIT-SAT is in NP:CIRCUIT-SAT is in NP: Construct 2-input polynomial-time algorithmConstruct 2-input polynomial-time algorithm A A that verifies that verifies

CIRCUIT-SATCIRCUIT-SAT Input 1: encoding of circuit CInput 1: encoding of circuit C Input 2: certificate = assignment of boolean values to Input 2: certificate = assignment of boolean values to allall wires of C wires of C

Algorithm Algorithm AA : : For each logic gate For each logic gate AA checks if certificate value for gate’s output wire checks if certificate value for gate’s output wire

correctly computes gate’s function based on input wire valuescorrectly computes gate’s function based on input wire values If output of entire circuit is 1, algorithm outputs 1If output of entire circuit is 1, algorithm outputs 1 Otherwise, algorithm outputs 0Otherwise, algorithm outputs 0

For satisfiable circuit, there is a (polynomial-length) certificate For satisfiable circuit, there is a (polynomial-length) certificate that causes that causes AA to output 1 to output 1

For unsatisfiable circuit, no certificate can cause For unsatisfiable circuit, no certificate can cause AA to output 1 to output 1 Algorithm Algorithm AA runs in polynomial time runs in polynomial time

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

NP-Completeness & Reducibility (continued) Circuit Satisfiability

CIRCUIT-SAT is NP-hard:CIRCUIT-SAT is NP-hard: LL represents some language in NP represents some language in NP Create polynomial-time algorithm Create polynomial-time algorithm

FF computing reduction function computing reduction function ff that maps every binary string that maps every binary string xx to to a circuit a circuit C=f(x)C=f(x) such that such that

Must exist algorithm Must exist algorithm AA verifying verifying LL

in polynomial time. (in polynomial time. (AA from NP) from NP) FF uses uses AA to compute to compute f.f. Represent computation of Represent computation of AA as as

sequence of configurationssequence of configurations FF constructs single circuit that constructs single circuit that

computes all configurations computes all configurations produced by initial configurationproduced by initial configuration

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

SATCIRCUITCLx

Circuit is tailor-made for instance string Circuit is tailor-made for instance string xx..

NP-Completeness Proofs (continued)

Proving a Language NP-CompleteProving a Language NP-Complete

Proving a Language NP-HardProving a Language NP-Hard all steps all steps except (1)except (1)

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

NP-Completeness Proofs (continued)

Reducing Boolean Circuit Satisfiability to Boolean Reducing Boolean Circuit Satisfiability to Boolean Formula SatisfiabilityFormula Satisfiability Boolean Formula SatisfiabilityBoolean Formula Satisfiability: Instance of language : Instance of language

SATSAT is a boolean formula is a boolean formula consisting of: consisting of: nn boolean variables: boolean variables: xx11, , xx22, ... , , ... , xxnn mm boolean connectives: boolean function with 1 or 2 inputs and 1 boolean connectives: boolean function with 1 or 2 inputs and 1

output output e.g. AND, OR, NOT, implication, iffe.g. AND, OR, NOT, implication, iff

parenthesesparentheses truth, satisfying assignments notions apply truth, satisfying assignments notions apply

}:{ formulabooleanesatisfiablaisSAT

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

NP-Completeness Proofs (continued)

ShowShow: SAT is NP-Complete: SAT is NP-Complete SAT is in NP via argument similar to circuit caseSAT is in NP via argument similar to circuit case Reduce Boolean Circuit Satisfiability to Boolean Reduce Boolean Circuit Satisfiability to Boolean

Formula SatisfiabilityFormula Satisfiability

Careful!Careful! Naive approach might have shared Naive approach might have shared subformulas and cause formula size to grow subformulas and cause formula size to grow exponentially!exponentially!

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

SATSATCIRCUIT P

NP-Completeness Proofs (continued)

ShowShow: SAT is NP-Complete : SAT is NP-Complete (continued)(continued) Reduce Boolean Circuit Satisfiability to Boolean Reduce Boolean Circuit Satisfiability to Boolean

Formula Satisfiability Formula Satisfiability (continued)(continued) ApproachApproach: For each wire : For each wire xxii in circuit in circuit CC, formula , formula

has variable has variable xxii. Express gate operation.. Express gate operation.

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

SATSATCIRCUIT P

)( 3410 xxx ))(( 215 xxx

)( 46 xx ))(( 4217 xxxx

))(( 658 xxx ))(( 769 xxx

))(( 98710 xxxx 34.10

CC

NP-Completeness Proofs (continued)

Reducing Formula Satisfiability to 3-CNF-Reducing Formula Satisfiability to 3-CNF-Satisfiability Satisfiability Boolean Formula SatisfiabilityBoolean Formula Satisfiability: Instance of language : Instance of language

SATSAT is a boolean formula is a boolean formula CNF = conjunctive normal formCNF = conjunctive normal form

conjunctionconjunction: AND of clauses: AND of clauses clauseclause: OR of literal(s): OR of literal(s)

3-CNF: each clause has 3-CNF: each clause has exactly 3exactly 3 distinct literals distinct literals ShowShow: 3-CNF is NP-Complete: 3-CNF is NP-Complete

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

CNFSAT P 3

NP-Completeness Proofs (continued)

ShowShow: 3-CNF is NP-Complete : 3-CNF is NP-Complete (continued)(continued) 3CNF is in NP via argument similar to circuit case3CNF is in NP via argument similar to circuit case Reduce Formula Satisfiability to 3-CNF-SatisfiabilityReduce Formula Satisfiability to 3-CNF-Satisfiability

3 steps progressively transforming formula 3 steps progressively transforming formula closer to 3CNF closer to 3CNF 1) Similar to 1) Similar to reduction reduction

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

CNFSAT P 3

SATSATCIRCUIT PBinary “ParseTree”Binary “ParseTree”

34.11

NP-Completeness Proofs (continued)

ShowShow: 3-CNF is NP-Complete : 3-CNF is NP-Complete (continued)(continued) 3CNF is in NP via argument similar to circuit case3CNF is in NP via argument similar to circuit case Reduce Formula Satisfiability to 3-CNF-SatisfiabilityReduce Formula Satisfiability to 3-CNF-Satisfiability

3 steps progressively transforming formula 3 steps progressively transforming formula closer to 3CNF closer to 3CNF 2) Convert each clause 2) Convert each clause ii

’’ into conjunctive normal form into conjunctive normal form construct truth table for construct truth table for ii

’’ using entries for 0, build DNF formula for using entries for 0, build DNF formula for convert DNF into CNF formula convert DNF into CNF formula ii

”” by applying DeMorgan’s laws by applying DeMorgan’s laws each clause has each clause has at mostat most 3 literals 3 literals

CNFSAT P 3

243121 )))(()(( xxxxxx

'i

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

truth table for truth table for 11

********

* use to build * use to build DNF DNF

NP-Completeness Proofs (continued)

ShowShow: 3-CNF is NP-Complete : 3-CNF is NP-Complete (continued)(continued) 3CNF is in NP via argument similar to circuit case3CNF is in NP via argument similar to circuit case Reduce Formula Satisfiability to 3-CNF-SatisfiabilityReduce Formula Satisfiability to 3-CNF-Satisfiability

3 steps progressively transforming formula 3 steps progressively transforming formula closer to 3CNF closer to 3CNF 3) Convert each clause 3) Convert each clause ii

” ” so it has so it has exactly 3 distinctexactly 3 distinct literals literals add “padding variables”add “padding variables” create create ii

”’ ”’

Size of resulting formula is polynomial in length of original Size of resulting formula is polynomial in length of original formula and reduction takes only polynomial time and 3-CNF formula and reduction takes only polynomial time and 3-CNF formula formula

CNFSAT P 3

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

esatisfiabl esatisfiabl '''

Expanding List of Hard Problems via Reduction

Relationships among some NP-complete problemsRelationships among some NP-complete problems

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al. source: Garey & Johnsonsource: Garey & Johnson

Circuit-SATCircuit-SATFirst NP-complete problem: First NP-complete problem: Boolean Formula Satisfiability (Cook ’71)Boolean Formula Satisfiability (Cook ’71)

Clique

source: Garey & Johnsonsource: Garey & Johnson

B

E

C

FD

A

CliqueClique of an undirected graph of an undirected graph G=(V,E) is a complete subgraph of G.G=(V,E) is a complete subgraph of G.

cliqueclique of size 3of size 3

Reducing 3-CNF-SAT to Clique

xx11

xx11

xx22xx22

xx11

xx33

Construct graph G such that Construct graph G such that is satisfiable iff G has clique of size is satisfiable iff G has clique of size kk

)( 321rrr

r lllCFor each clauseFor each clause place triple of vertices v place triple of vertices v11rr , v , v22

rr , v , v33rr into V. into V.

Put edge for v Put edge for viirr , v , vjj

ss if corresponding literals consistent and r not= s. if corresponding literals consistent and r not= s.

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

34.14

Vertex Cover

source: Garey & Johnson

B

E

C

FD

A

Vertex CoverVertex Cover of an undirected of an undirected graph G=(V,E) is a subsetgraph G=(V,E) is a subset

bothorVvorVuthenEvuifthatsuchVV '',),('

vertex coververtex cover of size 2of size 2

Reducing Clique to VertexCover

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

Construct complement G =(V, E ) of graph G such that G has Construct complement G =(V, E ) of graph G such that G has clique of size k iff graph G has a vertex cover of size |V|-k.clique of size k iff graph G has a vertex cover of size |V|-k.

zz ww

uu

yy

vv

xx

GinvertexisVVkVwithVcliqueVhasG cover'|'|'

GincliqueisVVkVVwithVVvertexhasG '|||'|'cover

34.15

Dominating Set

source: Garey & Johnsonsource: Garey & Johnson

Hamiltonian Cycle

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

Hamiltonian CycleHamiltonian Cycle of an undirected graph G=(V,E) is a of an undirected graph G=(V,E) is a simple cycle that contains each vertex in V.simple cycle that contains each vertex in V.

34.2

NP-Complete: see textbook’s reduction from VertexCoverNP-Complete: see textbook’s reduction from VertexCover

How to Treat

NP-Hard or Complete Problems

Some Techniques for Treating NP-Complete Problems

Approximation AlgorithmsApproximation Algorithms Heuristic Upper or Lower BoundsHeuristic Upper or Lower Bounds

GreedyGreedy, Simulated Annealing, Genetic “Alg”, AI, Simulated Annealing, Genetic “Alg”, AI Mathematical ProgrammingMathematical Programming

Linear Programming for part of problemLinear Programming for part of problem Integer ProgrammingInteger Programming Quadratic Programming...Quadratic Programming...

Search Space Exploration:Search Space Exploration: Gradient Descent, Local Search, Pruning, SubdivisionGradient Descent, Local Search, Pruning, Subdivision

RandomizationRandomization, Derandomization, Derandomization Leverage/Impose Problem StructureLeverage/Impose Problem Structure Leverage Similar ProblemsLeverage Similar Problems