Trevor Brown DC 2338, Office hour M3-4pm

Slides:



Advertisements
Similar presentations
Proof of correctness; More reductions
Advertisements

NP-Hard Nattee Niparnan.
Theory of Computing Lecture 18 MAS 714 Hartmut Klauck.
Lecture 23. Subset Sum is NPC
NP-Completeness: Reductions
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Complexity 11-1 Complexity Andrei Bulatov NP-Completeness.
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.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 23 Instructor: Paul Beame.
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
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
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle
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.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
Instructor Neelima Gupta Table of Contents Class NP Class NPC Approximation Algorithms.
28.
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
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
Costas Busch - LSU 1 More NP-complete Problems. Costas Busch - LSU 2 Theorem: If: Language is NP-complete Language is in NP is polynomial time reducible.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
The Theory of NP-Completeness
The NP class. NP-completeness
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
P & NP.
Chapter 10 NP-Complete Problems.
Richard Anderson Lectures NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
Polynomial-Time Reduction
More NP-complete Problems
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
Perfect Matchings in Bipartite Graphs
NP-Completeness Yin Tat Lee
CS21 Decidability and Tractability
Intro to Theory of Computation
CS154, Lecture 16: More NP-Complete Problems; PCPs
ICS 353: Design and Analysis of Algorithms
NP-Completeness (2) NP-Completeness Graphs 11/23/2018 2:12 PM x x x x
More NP-complete Problems
Richard Anderson Lecture 25 NP-Completeness
Richard Anderson Lecture 28 NP-Completeness
NP-Complete Problems.
Richard Anderson Lecture 26 NP-Completeness
NP-Completeness Yin Tat Lee
CS21 Decidability and Tractability
The Theory of NP-Completeness
CS154, Lecture 16: More NP-Complete Problems; PCPs
CS21 Decidability and Tractability
More NP-complete problems
CSE 589 Applied Algorithms Spring 1999
Instructor: Aaron Roth
Instructor: Aaron Roth
NP-Completeness (2) NP-Completeness Graphs 7/9/2019 6:12 AM x x x x x
Lecture 23 NP-Hard Problems
Presentation transcript:

Trevor Brown trevor.brown@uwaterloo.ca DC 2338, Office hour M3-4pm CS 341: Algorithms Trevor Brown trevor.brown@uwaterloo.ca DC 2338, Office hour M3-4pm

This time Proving NP-completeness for several problems 3-SAT Clique Vertex Cover Subset Sum (partially)

Polynomial transformation the most convenient definition Recall from last time Let Π 1 and Π 2 be decision problems Π 1 ≤ 𝑃 Π 2 iff there exists 𝑓 :ℐ Π 1 →ℐ( Π 2 ) such that: 𝑓(𝐼) is computable in poly-time, for all 𝐼∈ℐ( Π 1 ) 𝐼∈ ℐ 𝑦𝑒𝑠 ( Π 1 ) iff 𝑓 𝐼 ∈ ℐ 𝑦𝑒𝑠 ( Π 2 )

Recall from last time 3-SAT 2-SAT

Reducing SAT to 3-SAT (Proving SAT ≤ 𝑃 3-SAT)

Is sat harder than 3-sat? Not really… Recall from last time Let’s prove this is a polynomial transformation Complexity? Correctness?

Recall from last time: SAT is NP-complete Every problem in NP reduces to reduces to Since SAT is NP-complete, so is 3-SAT! Let’s show 3-SAT also reduces to some other problem in NP… This will prove the other problem is NP-complete

Reducing 3-SAT to Clique (Proving 3-SAT ≤ 𝑃 Clique)

Showing 3-SAT ≤ 𝑃 Clique Complexity? Correctness? Let 𝐼 be an instance of 3-SAT with 𝑛 variables 𝑥 1 … 𝑥 𝑛 and 𝑚 clauses 𝐶 1 … 𝐶 𝑚 E.g., 𝑥 1 ∨ 𝑥 2 ∨ 𝑥 3 ∧ 𝑥 1 ∨ 𝑥 2 ∨ 𝑥 3 ∧ 𝑥 2 ∨ 𝑥 3 ∨ 𝑥 5 ∧( 𝑥 3 ∨ 𝑥 4 ∨ 𝑥 5 ) [𝑛=5,𝑚=4] We construct Clique input 𝒇 𝑰 =(𝑮,𝒌) Node 𝑣 𝑡 𝑐 for each term 1≤𝑡≤3 in each clause 1≤𝑐≤𝑚 (so V =3𝑚) Edges between all non-contradictory pairs of nodes (no 𝑥 𝑖 ∧ 𝑥 𝑖 ) in different clauses 𝑘=𝑚 (sub-problem is to find an 𝒎-clique) Must prove this is a polynomial transformation 𝐶 1 : 𝑣 1 1 𝑥 1 𝑣 2 1 𝑥 2 𝑣 3 1 𝑥 3 𝐶 2 : 𝑣 1 2 𝑥 1 𝑣 2 2 𝑥 2 𝑣 3 2 𝑥 3 𝑣 1 3 𝑥 2 𝑣 2 3 𝑥 3 𝑣 3 3 𝑥 5 𝑣 1 4 𝑥 3 𝑣 2 3 𝑥 4 𝑣 3 3 𝑥 5 Complexity? Correctness?

Showing 3-SAT ≤ 𝑃 Clique Let 𝐼 be an instance of 3-SAT with 𝑛 variables 𝑥 1 … 𝑥 𝑛 and 𝑚 clauses 𝐶 1 … 𝐶 𝑚 E.g., 𝑥 1 ∨ 𝑥 2 ∨ 𝑥 3 ∧ 𝑥 1 ∨ 𝑥 2 ∨ 𝑥 3 ∧ 𝑥 2 ∨ 𝑥 3 ∨ 𝑥 5 ∧( 𝑥 3 ∨ 𝑥 4 ∨ 𝑥 5 ) Case 1: Suppose 𝐼 is a yes-instance of 3-SAT, and show 𝒇 𝑰 is a yes-instance of 𝒎-clique Since 𝐼 is a yes-instance, ∃ a satisfying assignment E.g., 𝑥 1 =1, 𝑥 2 =1, 𝑥 3 =1, 𝑥 4 =1, 𝑥 5 =0 Select one true term 𝑻 𝒊 from each clause 𝑪 𝒊 E.g., 𝑇 1 = 𝑥 1 , 𝑇 2 = 𝑥 2 , 𝑇 3 = 𝑥 3 , 𝑇 4 = 𝑥 5 Claim: the corresponding nodes form an 𝒎-clique There are 𝑚 of these nodes, each in a different clause None of them have contradictory truth assignments So, there are edges between all pairs of them  they form an 𝑚-clique 𝒗 𝟏 𝟏 𝑣 1 1 𝒙 𝟏 𝑥 1 𝑥 1 𝑣 2 1 𝑥 2 𝑣 3 1 𝑥 3 𝑣 1 2 𝑥 1 𝒗 𝟐 𝟐 𝑣 2 2 𝒙 𝟐 𝑥 2 𝑥 2 𝑣 3 2 𝑥 3 𝑣 1 3 𝑥 2 𝒗 𝟐 𝟑 𝑣 2 3 𝒙 𝟑 𝑥 3 𝑥 3 𝑣 3 3 𝑥 5 𝑣 1 4 𝑥 3 𝑣 2 3 𝑥 4 𝒗 𝟑 𝟑 𝑣 3 3 𝒙 𝟓 𝑥 5 𝑥 5

Showing 3-SAT ≤ 𝑃 Clique Let 𝐼 be an instance of 3-SAT with 𝑛 variables 𝑥 1 … 𝑥 𝑛 and 𝑚 clauses 𝐶 1 … 𝐶 𝑚 E.g., 𝑥 1 ∨ 𝑥 2 ∨ 𝑥 3 ∧ 𝑥 1 ∨ 𝑥 2 ∨ 𝑥 3 ∧ 𝑥 2 ∨ 𝑥 3 ∨ 𝑥 5 ∧( 𝑥 3 ∨ 𝑥 4 ∨ 𝑥 5 ) Case 2: Suppose 𝒇(𝑰) is a yes-instance of 𝑚-clique, and show 𝐼 is a yes-instance of 3-SAT Since 𝑓(𝐼) is a yes-instance, it contains an 𝑚-clique Clique contains edges between all pairs of nodes There are no edges between nodes in same clause, so clique contains one node from each clause Set the corresponding terms to be true Clique contains no edges between contradictory terms (i.e., no edge connects 𝑥 𝑖 and 𝑥 𝑖 for any 𝑖) So, truth assignment is consistent and satisfies each clause (and the formula) 𝒗 𝟏 𝟏 𝑣 1 1 𝒙 𝟏 𝑥 1 𝑥 1 𝑣 2 1 𝑥 2 𝑣 3 1 𝑥 3 𝑣 1 2 𝑥 1 𝒗 𝟐 𝟐 𝑣 2 2 𝒙 𝟐 𝑥 2 𝑥 2 𝑣 3 2 𝑥 3 𝑣 1 3 𝑥 2 𝒗 𝟐 𝟑 𝑣 2 3 𝒙 𝟑 𝑥 3 𝑥 3 𝑣 3 3 𝑥 5 𝑣 1 4 𝑥 3 𝑣 2 3 𝑥 4 𝒗 𝟑 𝟑 𝑣 3 3 𝒙 𝟓 𝑥 5 𝑥 5

Every problem in NP reduces to reduces to

Recall: Vertex Cover problem 𝒌 2-vertex cover Can I find 𝒌 nodes that touch every edge in the graph?

This additional polynomial transformation was proved last class! Every problem in NP reduces to reduces to This additional polynomial transformation was proved last class! Let’s reduce vertex cover to some other problem…

Reducing Vertex-Cover to Subset-Sum (Proving Vertex-Cover ≤ 𝑃 Subset-Sum)

Subset-Sum (slightly different from before) Earlier, we defined Subset-Sum with a target sum of 0 Here we generalize slightly to target sum T Goal: transform instance 𝐼 of VC into instance 𝑓 𝐼 of SS (in poly time) such that 𝐼 is a yes-instance of VC iff 𝑓(𝐼) is a yes-instance of SS Idea: turn nodes and edges into a list of “sizes” and a target sum. Target sum should be achievable IFF there is a k-vertex cover. Somehow want each node size to encode which edges are covered by the node, and target sum to encode that each edge is covered (by some node)

Give a unique size of 10 𝑗 to each edge 𝑒 𝑗 Input to Vertex Cover Sort of like an adjacency matrix, but instead of storing which node-pairs are adjacent, store which edges are incident to each node Why twice? If both endpoints of 𝑒 𝑗 are in the vertex cover, it is counted twice. Otherwise once, and can add 𝑏 𝑗 . Give a size to each node equal to ( 10 𝑚 + sizes of all edges incident to the node) This target weight asks for 𝒌 nodes and for all edges to be included twice Give a unique size of 10 𝑗 to each edge 𝑒 𝑗

Example Node 𝑣 2 is not incident to edge 𝑒 0 All 5 edges counted twice Looking for 2 nodes All 5 edges counted twice Edge 𝑒 0 Edge 𝑒 1 Edge 𝑒 4 Node 𝑣 2 is incident to edge 𝑒 1 # encodes info about incident edges Node 𝑣 1 edge Is there a 2-VC? Use subset sum to search for 𝑊=𝟐22222 # looks the same as the incidence matrix! Node 𝑣 2 We find 𝑊= 𝒂 𝟐 + 𝒂 𝟑 + 𝑏 0 + 𝑏 1 + 𝑏 3 + 𝑏 4 node Sum of edge sizes incident to 𝑣 1 Vertex cover is 𝑉 ′ ={ 𝑣 2 , 𝑣 3 }. 𝑒 2 has both endpoints in 𝑉 ′ , so 𝑎 2 + 𝑎 3 contributes 𝟐×𝒔𝒊𝒛𝒆( 𝒆 𝟐 ) to 𝑊 Node 𝑣 5 = Note: no “carrying” can occur even if we sum everything explain one endpoint vs both endpoints in VC Every other edge 𝑒 ℓ has only one endpoint in 𝑉′, so 𝑎 2 + 𝑎 3 contributes only 𝟏×𝒔𝒊𝒛𝒆 𝒆 ℓ to 𝑊. So a second 𝑠𝑖𝑧𝑒( 𝑒 ℓ ) is added by 𝑏 ℓ (for each 𝑒 ℓ ). First digit of 𝑊 accurately captures # of nodes in the sum Other digits can be between 0 and 3. An edge is definitely covered if its digit is 2.

We stopped here

Case 1: Suppose 𝐼 is a yes-instance of Vertex-Cover. one endpoint in 𝑉 ′ both endpoints in 𝑉 ′ Contains edge sizes Contains node sizes 𝑒 𝑗 has one endpoint in 𝑉 ′ , so nodes in 𝑉 ′ contribute 𝟏×𝒔𝒊𝒛𝒆( 𝒆 𝒋 ) to 𝑊 𝑒 𝑗 has both endpoints in 𝑉 ′ , so nodes in 𝑉 ′ contribute 𝟐×𝒔𝒊𝒛𝒆( 𝒆 𝒋 ) to 𝑊 Add another 𝟏×𝒔𝒊𝒛𝒆( 𝒆 𝒋 ) to 𝑊 for each 𝑒 𝑗 with one endpoint in 𝑉 ′ In future it would be nice to rename A’ -> N’, B’ -> E’, or *something* more memorable than A and B. something that encodes the fact that A’ contains node sizes, and B’ contains edge sizes. To get 2×𝑠𝑖𝑧𝑒( 𝑒 𝑗 ) for all 𝑒 𝑗 , plus 10 𝑚 for each node

Case 2: Suppose 𝑓(𝐼) is a yes-instance of Subset Sum. We show 𝐼 is a yes-instance of Vertex-Cover Since 𝑓(𝐼) is a yes-instance, there exists 𝐴 ′ ∪ 𝐵 ′ that sums to 𝑊 where 𝐴′ contains node sizes and 𝐵′ contains edge sizes Define 𝑉 ′ = 𝑣 𝑖 : 𝑎 𝑖 ∈ 𝐴 ′ . We claim 𝑉′ is a vertex cover of size 𝑘. We must have 𝑉 ′ =𝑘 to get the coefficient of 10 𝑚 to be 𝑘 The coefficient of every other term 10 𝑗 (𝑗≤𝑚−1) must be 2 Suppose (for contra.) 𝑉′ does not cover some edge 𝑒 𝑗 =(𝑢,𝑣) Then the coefficient of 10 𝑗 is zero for every 𝑎 𝑖 ∈ 𝐴 ′ But the coefficient of 10 𝑗 is 2, so a subset of 𝐵′ must sum to 2× 10 𝑗 But this is impossible (so 𝑒 𝑗 is covered, so all edges are covered)

Complexity of the transformation Assume adjacency matrix and unit cost model for simplicity Complexity of the transformation Compute 𝐶 with trivial algorithm in 𝑂(𝑛𝑚) time Compute 𝑎 𝑖 by visiting all incident edges. Trivial algorithm yields 𝑂(𝑚) time for each 𝑎 𝑖 , totaling 𝑂(𝑛+𝑚) over all 𝑖 Trivial to compute all 𝑏 𝑗 in 𝑂(𝑚) time Trivial to compute 𝑊 in 𝑂(𝑚) time Total 𝑂(𝑛𝑚) time. This is polynomial in the input graph size!