TU/e Algorithms (2IL15) – Lecture 10 1 NP-Completeness, II.

Slides:



Advertisements
Similar presentations
Theory of Computing Lecture 18 MAS 714 Hartmut Klauck.
Advertisements

Lecture 21 NP-complete problems
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
Complexity 11-1 Complexity Andrei Bulatov NP-Completeness.
CS21 Decidability and Tractability
February 23, 2015CS21 Lecture 201 CS21 Decidability and Tractability Lecture 20 February 23, 2015.
Computability and Complexity 15-1 Computability and Complexity Andrei Bulatov NP-Completeness.
Graphs 4/16/2017 8:41 PM NP-Completeness.
Transitivity of  poly Theorem: Let ,  ’, and  ’’ be three decision problems such that   poly  ’ and  ’  poly  ’’. Then  poly  ’’. Proof:
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
1 Polynomial Time Reductions Polynomial Computable function : For any computes in polynomial time.
NP-Complete Problems Problems in Computer Science are classified into
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 23 Instructor: Paul Beame.
NP-Completeness (2) NP-Completeness Graphs 4/17/2017 6:25 AM x x x x x
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Clique Cover Cook’s Theorem 3SAT and Independent Set
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Lecture 22 More NPC problems
CSEP 521 Applied Algorithms Richard Anderson Lecture 10 NP Completeness.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle
Prabhas Chongstitvatana1 NP-complete proofs The circuit satisfiability proof of NP- completeness relies on a direct proof that L  p CIRCUIT-SAT for every.
Polynomial-time reductions We have seen several reductions:
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
CSC401 – Analysis of Algorithms Chapter 13 NP-Completeness Objectives: Introduce the definitions of P and NP problems Introduce the definitions of NP-hard.
Additional NP-complete problems
Unit 9: Coping with NP-Completeness
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
NP-Completeness (Nondeterministic Polynomial Completeness) Sushanth Sivaram Vallath & Z. Joseph.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
NPC.
NP Completeness Piyush Kumar. Today Reductions Proving Lower Bounds revisited Decision and Optimization Problems SAT and 3-SAT P Vs NP Dealing with NP-Complete.
CSC 413/513: Intro to Algorithms
NP-Completeness Note. Some illustrations are taken from (KT) Kleinberg and Tardos. Algorithm Design (DPV)Dasgupta, Papadimitriou, and Vazirani. Algorithms.
1 Ch 10 - NP-completeness Tractable and intractable problems Decision/Optimization problems Deterministic/NonDeterministic algorithms Classes P and NP.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
TU/e Algorithms (2IL15) – Lecture 9 1 NP-Completeness NOT AND OR AND NOT AND.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
COMPLEXITY. Satisfiability(SAT) problem Conjunctive normal form(CNF): Let S be a Boolean expression in CNF. That is, S is the product(and) of several.
34.NP Completeness. Computer Theory Lab. Chapter 34P.2.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
P, NP, NP-completeness 2 Reductions 1 Thu, July 7 th 1.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
NP-Completeness (2) NP-Completeness Graphs 4/13/2018 5:22 AM x x x x x
More NP-Complete and NP-hard Problems
More NP-complete problems
Richard Anderson Lectures NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
Advanced Algorithms Analysis and Design
NP-Completeness (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
NP-Completeness (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
NP-Completeness Proofs
Richard Anderson Lecture 26 NP-Completeness
Hard Problems Introduction to NP
Intro to Theory of Computation
ICS 353: Design and Analysis of Algorithms
NP-Completeness (2) NP-Completeness Graphs 11/23/2018 2:12 PM x x x x
Richard Anderson Lecture 25 NP-Completeness
Richard Anderson Lecture 28 NP-Completeness
Chapter 34: NP-Completeness
NP-Complete Problems.
Richard Anderson Lecture 26 NP-Completeness
CSE 589 Applied Algorithms Spring 1999
NP-Completeness (2) NP-Completeness Graphs 7/9/2019 6:12 AM x x x x x
Presentation transcript:

TU/e Algorithms (2IL15) – Lecture 10 1 NP-Completeness, II

TU/e Algorithms (2IL15) – Lecture 10 2 Summary of previous lecture P: class of decision problems that can be solved in polynomial time NP: decision problems for which there exists a polynomial-time verifier algorithm A with two inputs − input to the problem: x − certificate: y A is polynomial-time verifier: if and only if x is “yes”-instance, there exists certificate y such that A(x,y) outputs “yes”, and A runs in polynomial time in x for such instances “NP" = non-deterministically polynomial: with luck, a polynomial-time algorithm could recognise a yes-instance of a problem by guessing the certificate right and verifying it---but we don't know how to build lucky computers...

TU/e Algorithms (2IL15) – Lecture 10 3 Summary of previous lecture (cont’d) Reductions problem A is polynomial-time reducible to problem B if there is a reduction algorithm mapping instances of A to instances of problem B such that  “yes”-instances of A are mapped to “yes”-instances of B  “no”-instances of A are mapped to “no”-instances of B  the reduction algorithm runs in polynomial time Notation: problem A ≤ P problem B

TU/e Algorithms (2IL15) – Lecture 10 4 Summary of previous lecture (cont’d) NP-complete problems: problems A in NP such that B ≤ P A for any B in NP (if you can solve any NP-complete problem in polynomial time, then you can solve every NP-complete problem in polynomial time) NP-complete problems cannot be solved in polynomial time, unless P = NP Circuit-SAT Input: combinatorial Boolean circuit Question: Can variables be set such that formula evaluates to true ? Theorem: Circuit-SAT is NP-complete NOT AND OR AND NOT AN D x1x1 x3x3 x2x2 x4x4

TU/e Algorithms (2IL15) – Lecture 10 5 Proving NP-completeness of other problems Theorem: If problem A is NP-hard and problem A ≤ P problem B, then problem B is also NP-hard. General strategy to prove that a problem B is NP-complete  Select problem A that is known to be NP-complete.  Prove that A ≤ P B:  Describe reduction algorithm, which maps instances x of A to instances f (x) of B.  Prove that x is “yes”-instance for A iff f (x) is “yes”-instance for B  Prove that reduction algorithm runs in polynomial time (Now you have shown that B is NP-hard.)  Prove that B is in NP by giving polynomial-time verification algorithm.

TU/e Algorithms (2IL15) – Lecture 10 6 Summary of previous lecture (cont’d) SATISFIABILITY Input: Boolean formula Question: Can variables be set such that formula evaluates to true ? Theorem: SATISFIABILITY is NP-complete Proof by reduction from Circuit-SAT TODAY: More reductions, more NP-complete problems ( (x 1 → ¬x 3 ) ↔ (x 1 V ¬x 2 V x 3 ) ) Λ (¬ (x 2 V x 3 V x 5 ) → (x 1 V x 3 V x 4 ) )

TU/e Algorithms (2IL15) – Lecture 10 7 Boolean formula in 3-CNF form:  “AND” of a number of clauses  each clause the “OR” of exactly three literals 3-SAT Input: Boolean formula in 3-CNF form Question: Can variables be set such that formula evaluates to true ? In the book problem is called 3-CNF-SAT, but most people just call it 3-SAT. ( x 1 V x 2 V ¬x 3 ) Λ (x 2 V ¬x 4 V ¬x 5 ) Λ (¬x 2 V x 3 V x 5 ) Λ (x 1 V x 3 V x 4 )

TU/e Algorithms (2IL15) – Lecture 10 8 Theorem: 3-SAT is NP-complete Proof. Step 1: Select suitable NP-hard problem: Circuit-Sat or SATISFIABILITY ? SATISFIABILITY Step 2: Give polynomial-time reduction from SATISFIABILITY to 3-SAT Convert arbitrary Boolean formula F into formula F* in 3-CNF form ( (x 1 → ¬x 3 ) ↔ (x 1 V ¬x 2 V x 3 ) ) Λ (¬ (x 2 V x 3 V x 5 ) → (x 1 V x 3 V x 4 ) ) (.. V.. V.. ) Λ … Λ (.. V.. V.. )

TU/e Algorithms (2IL15) – Lecture 10 9 Convert arbitrary Boolean formula F into formula F* in 3-CNF form ( (x 1 → ¬x 3 ) ↔ (x 1 V ¬x 2 V x 3 ) ) Λ (¬ (x 2 V x 3 V x 5 ) → (x 1 V x 3 V x 4 ) ) V ¬ V ↔ → Λ x1x1 ¬ x 2 x3x3 x2x2 x3x3 x5x5 x1x1 x3x3 x4x4 V first: convert to tree representation → x1x1 ¬ x 3 x1x1 ¬ x 2 V V x3x3 x2x2 x3x3 x5x5 V V binary

TU/e Algorithms (2IL15) – Lecture Convert arbitrary Boolean formula F into formula F* in 3-CNF form V ¬ V ↔ → Λ x1x1 ¬ x 2 x3x3 x2x2 x3x3 x5x5 x1x1 x3x3 x4x4 V second: − introduce extra variable y i for output of every internal node − write formulas for relations between variables: → x1x1 ¬ x 3 x1x1 ¬ x 2 V V x3x3 x2x2 x3x3 x5x5 V V y 1 ↔ ( y 2 Λ y 3 ) y 2 ↔ ( y 4 ↔ y 5 ) y 4 ↔ ( x 1 → ¬ x 3 ) etc y1y1 y2y2 y4y4 y3y3 y6y6 y5y5 y7y7 y8y8 y9y9 y 10

TU/e Algorithms (2IL15) – Lecture Convert arbitrary Boolean formula F into formula F* in 3-CNF form V ¬ V ↔ → Λ x1x1 ¬ x 2 x3x3 x2x2 x3x3 x5x5 x1x1 x3x3 x4x4 V third: − write formula to express satisfiability of the whole thing → x1x1 ¬ x 3 x1x1 ¬ x 2 V V x3x3 x2x2 x3x3 x5x5 V V y 1 ↔ ( y 2 Λ y 3 ) y 2 ↔ ( y 4 ↔ y 5 ) y 4 ↔ ( x 1 → ¬ x 3 ) etc y1y1 y2y2 y4y4 y3y3 y6y6 y5y5 y7y7 y8y8 y9y9 y 10 y 1 Λ (y 1 ↔ ( y 2 Λ y 3 )) Λ (y 2 ↔ ( y 4 ↔ y 5 )) Λ … final output TRUE output of nodes consistent with children

TU/e Algorithms (2IL15) – Lecture Convert arbitrary Boolean formula F into formula F* in 3-CNF form fourth: − rewrite each clause into CNF-form y 1 Λ (y 1 ↔ ( y 2 Λ y 3 )) Λ (y 2 ↔ ( y 4 ↔ y 5 )) Λ … final output TRUE output of nodes consistent with children y 1 y 2 y 3 y 1 ↔ ( y 2 Λ y 3 ) … … clause is equivalent to: ¬ ( ( y 1 Λ y 2 Λ ¬y 3 ) V ( y 1 Λ ¬ y 2 Λ y 3 ) V … ) Use De Morgan: ¬ ( a Λ b) ≡ (¬a V ¬b) etc (¬ y 1 V ¬ y 2 V y 3 ) Λ (¬ y 1 V y 2 V ¬ y 3 ) …

TU/e Algorithms (2IL15) – Lecture Convert arbitrary Boolean formula F into formula F* in 3-CNF form after fourth step we have formula in CNF-form … y 1 Λ (¬ y 1 V ¬ y 2 V y 3 ) Λ (¬ y 1 V y 2 V ¬ y 3 ) Λ … … but some clauses have only one or two literals fifth: − add extra variables and use them to “fill up” these clauses For example: use extra variables p, q to replace y 1 by ( y 1 V p V q ) Λ ( y 1 V ¬p V q ) Λ ( y 1 V p V ¬ q ) Λ ( y 1 V ¬ p V ¬ q )

TU/e Algorithms (2IL15) – Lecture Convert arbitrary Boolean formula F into formula F* in 3-CNF form after fifth step we have  formula F* in 3-CNF-form …  … that is satisfiable if and only if original formula F is satisfiable  … and conversion can be done in polynomial time

TU/e Algorithms (2IL15) – Lecture Theorem: 3-SAT is NP-complete Proof. Step 1: Select suitable NP-hard problem: Circuit-Sat or SATISFIABILITY ? SATISFIABILITY Step 2: Give polynomial-time reduction from SATISFIABILITY to 3-SAT Convert arbitrary Boolean formula F into formula F* in 3-CNF form Step 3. Prove 3-SAT is in NP by giving polynomial-time verification algorithm. certificate = satisfying assignment

TU/e Algorithms (2IL15) – Lecture G = (V,E) is undirected graph clique in G: subset C V such that (u,v) in E for all pairs u,v in C CLIQUE Input: undirected graph G = (V,E) and a positive integer k Question: Does G have a clique of size k ? ∩

TU/e Algorithms (2IL15) – Lecture Theorem: CLIQUE is NP-complete Proof. Step 1: Select suitable NP-hard problem: Circuit-Sat, SATISFIABILITY or 3-SAT ? 3-SAT Step 2: Give polynomial-time reduction from 3-SAT to CLIQUE

TU/e Algorithms (2IL15) – Lecture Polynomial-time reduction from 3-SAT to CLIQUE F: 3-SAT formula (¬x 1 V x 2 V x 3 ) Λ (x 1 V ¬x 2 V ¬x 3 ) Λ (¬x 1 V ¬x 2 V x 3 ) Construct graph G = (V,E ) as follows x2x2 ¬x 1 x3x3 x1x1 ¬x 2 ¬x 3 ¬x 2 x3x3  introduce node for each literal in each clause of F  put edge between each pair of nodes such that −nodes are in different clauses −nodes are not each other’s opposite

TU/e Algorithms (2IL15) – Lecture x2x2 ¬x 1 x3x3 x1x1 ¬x 2 ¬x 3 ¬x 2 x3x3  introduce node for each literal in each clause of F  put edge between each pair of nodes such that −nodes are in different clauses −nodes are not each other’s opposite k = number of clauses of F Lemma: F is satisfiable G has clique of size at least k : Assume F is satisfiable. For each clause, select TRUE node. Then these nodes must form a clique. : Assume G has clique of size at least k. Set variables such that these nodes evaluate to TRUE. Must be a consistent setting that makes F true. Proof:

TU/e Algorithms (2IL15) – Lecture Theorem: CLIQUE is NP-complete Proof. Step 1: Select suitable NP-hard problem: Circuit-Sat, SATISFIABILITY or 3-SAT ? 3-SAT Step 2: Give polynomial-time reduction from 3-SAT to CLIQUE Reduction maps “yes”-instances to “yes”-instances and “no”-instances to “no”-instances. Reduction runs in time O( (#clauses) 2 ). Step 3. Prove CLIQUE is in NP by giving polynomial-time verification algorithm. certificate = subset of vertices forming clique of required size

TU/e Algorithms (2IL15) – Lecture G = (V,E) is undirected graph vertex cover in G: subset C V such that for each edge (u,v) in E we have u in C or v in C (or both) Vertex Cover Input: undirected graph G = (V,E) and a positive integer k Question: Does G have a vertex cover of size k ? ∩

TU/e Algorithms (2IL15) – Lecture Theorem: Vertex Cover is NP-complete Proof. Step 1: Select suitable NP-hard problem: Circuit-Sat, SATISFIABILITY, 3-SAT, or CLIQUE? CLIQUE Step 2: Give polynomial-time reduction from CLIQUE to Vertex Cover GG Construct complement G Lemma: subset W V is clique in G subset V−W is cover in G ∩

TU/e Algorithms (2IL15) – Lecture Theorem: Vertex Cover is NP-complete Proof. Step 1: Select suitable NP-hard problem: Circuit-Sat, SATISFIABILITY, 3-SAT, or CLIQUE? CLIQUE Step 2: Give polynomial-time reduction from CLIQUE to Vertex Cover  W is clique in G iff V−W is vertex cover in complement G  G has clique of size ≥ k iff G has vertex cover of size ≤ |V |-k so “yes”-instances map to “yes”-instances, and “no”-instances …  Reduction can be done in O( |V | 2 ) time Step 3. Prove Vertex Cover in NP by giving polynomial-time verification algorithm. certificate = subset of vertices that is cover of required size

TU/e Algorithms (2IL15) – Lecture Subset Sum Input: set X of non-negative integers, non-negative integer k Question: Does X have a subset S such that ∑ x in S x = k ? Example: X = { 1, 3, 3, 5, 7, 11, 17, 23, 41 } k = 25 S = { 3, 5, 17}

TU/e Algorithms (2IL15) – Lecture Theorem: Subset Sum is NP-complete Proof. Step 1: Select suitable NP-hard problem: Circuit-Sat, SATISFIABILITY, 3-SAT, CLIQUE, Vertex Cover ? 3-SAT Step 2: Give polynomial-time reduction from 3-SAT to Subset Sum Have to convert 3-SAT instance to Subset-Sum instance. WARNING: When converting to a problem involving numbers, make sure that numbers do not become too large. Explicitly work with binary (or base-10) representation.

TU/e Algorithms (2IL15) – Lecture A polynomial-time reduction from 3-SAT to Subset Sum F: 3-SAT formula with clauses C 1,…,C m over variables x 1,...,x n Convert F to set S of 2n+2m numbers, each consisting of n+m digits (base 10) ( First, remove clauses containing both x i and ¬x i for some i ) ( x 1 V x 2 V ¬x 3 ) Λ (x 2 V ¬x 3 V ¬x 4 ) Λ (¬x 1 V ¬x 2 V x 4 ) x1x1 x2x2 x3x3 x4x4 C1C1 C2C2 C3C3 v 1, v 1, v 2, v 2, c 1, c 1, two numbers per variable, representing TRUE and FALSE two numbers per clause v 1,1 = c 1,2 =

TU/e Algorithms (2IL15) – Lecture x1x1 x2x2 x3x3 x4x4 C1C1 C2C2 C3C3 v 1, v 1, v 2, v 2, c 1, c 1, two numbers per clause v 1,1 = c 1,2 = n times m times target sum (k) two numbers per variable, representing TRUE and FALSE for each clause, must make at least one literal TRUE ; if at least one literal TRUE, can select “clause numbers” to get to 4 must choose exactly one from each pair v i,1,v i,2 Lemma: F has satisfying assigment S has subset summing to 1…14…4

TU/e Algorithms (2IL15) – Lecture Theorem: Subset Sum is NP-complete Proof. Step 1: Select suitable NP-hard problem: Circuit-Sat, SATISFIABILITY, 3-SAT, CLIQUE, Vertex Cover ? 3-SAT Step 2: Give polynomial-time reduction from 3-SAT to Subset Sum Can convert 3-SAT instance to Subset-Sum instance in O((n+m) 2 ) time, based on representation base-10. Step 3. Prove Subset Sum in NP by giving polynomial-time verification algorithm. certificate = subset summing to k.

TU/e Algorithms (2IL15) – Lecture G = (V,E) is undirected graph Hamiltonian cycle in G: cycle that visits every vertex exactly once Hamiltonian Cycle Input: undirected graph G = (V,E) Question: Does G have a Hamiltonian cycle?

TU/e Algorithms (2IL15) – Lecture Theorem: Hamiltonian Cycle is NP-complete Proof. Step 1: Select suitable NP-hard problem: Circuit-Sat, SATISFIABILITY, 3-SAT, CLIQUE, VertexCover, SubsetSum? Vertex Cover Step 2: Give polynomial-time reduction from Vertex Cover to Ham-Cycle

TU/e Algorithms (2IL15) – Lecture A polynomial-time reduction from Vertex Cover to Ham-Cycle

TU/e Algorithms (2IL15) – Lecture Theorem: Hamiltonian Cycle is NP-complete Proof. Step 1: Select suitable NP-hard problem: Circuit-Sat, SATISFIABILITY, 3-SAT, CLIQUE, VertexCover, SubsetSum? Vertex Cover Step 2: Give polynomial-time reduction from Vertex Cover to Ham-Cycle Complicated, but can be done. Step 3. Prove Ham-Cycle in NP by giving polynomial-time verification algorithm. certificate = permutation of vertices forming a cycle

TU/e Algorithms (2IL15) – Lecture Summary Circuit-SAT SATISFIABILITY 3-SAT Clique Vertex Cover Hamiltonian Cycle TSP Subset Sum You should know these problems are NP-complete and study these reductions to learn some tricks that you may able to apply in other proofs. previous lecture