Reductions & NP-completeness as part of Foundations of Computer Science undergraduate course



Similar documents
Lecture 7: NP-Complete Problems

Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

One last point: we started off this book by introducing another famously hard search problem:

Why? A central concept in Computer Science. Algorithms are ubiquitous.

Complexity Theory. IE 661: Scheduling Theory Fall 2003 Satyaki Ghosh Dastidar

Page 1. CSCE 310J Data Structures & Algorithms. CSCE 310J Data Structures & Algorithms. P, NP, and NP-Complete. Polynomial-Time Algorithms

Introduction to Logic in Computer Science: Autumn 2006

NP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness

Computer Algorithms. NP-Complete Problems. CISC 4080 Yanjun Li

Introduction to Algorithms. Part 3: P, NP Hard Problems

Lecture 19: Introduction to NP-Completeness Steven Skiena. Department of Computer Science State University of New York Stony Brook, NY

OHJ-2306 Introduction to Theoretical Computer Science, Fall

CMPSCI611: Approximating MAX-CUT Lecture 20

Problem Set 7 Solutions

Discuss the size of the instance for the minimum spanning tree problem.

CSC 373: Algorithm Design and Analysis Lecture 16

Notes on NP Completeness

2. (a) Explain the strassen s matrix multiplication. (b) Write deletion algorithm, of Binary search tree. [8+8]

The Traveling Beams Optical Solutions for Bounded NP-Complete Problems

Graph Theory Problems and Solutions

CoNP and Function Problems

CAD Algorithms. P and NP

1. Nondeterministically guess a solution (called a certificate) 2. Check whether the solution solves the problem (called verification)

On the Unique Games Conjecture

A Working Knowledge of Computational Complexity for an Optimizer

Guessing Game: NP-Complete?

Chapter. NP-Completeness. Contents

Theoretical Computer Science (Bridging Course) Complexity

Tetris is Hard: An Introduction to P vs NP

Chapter 6: Graph Theory

Tutorial 8. NP-Complete Problems

DATA ANALYSIS II. Matrix Algorithms

! X is a set of strings. ! Instance: string s. ! Algorithm A solves problem X: A(s) = yes iff s! X.

On Frequency Assignment in Cellular Networks

Applied Algorithm Design Lecture 5

The Classes P and NP. mohamed@elwakil.net

V. Adamchik 1. Graph Theory. Victor Adamchik. Fall of 2005

Social Media Mining. Graph Essentials

Where the Really Hard Problems Are

P versus NP, and More

Social Media Mining. Network Measures

CS311H. Prof: Peter Stone. Department of Computer Science The University of Texas at Austin

Bicolored Shortest Paths in Graphs with Applications to Network Overlay Design

5.1 Bipartite Matching

Cloud Computing is NP-Complete

An Introduction to APGL

Data Structures and Algorithms Written Examination

Notes on Excel Forecasting Tools. Data Table, Scenario Manager, Goal Seek, & Solver

Analysis of Algorithms, I

THE PROBLEM WORMS (1) WORMS (2) THE PROBLEM OF WORM PROPAGATION/PREVENTION THE MINIMUM VERTEX COVER PROBLEM

Introduction to computer science

136 CHAPTER 4. INDUCTION, GRAPHS AND TREES

Network (Tree) Topology Inference Based on Prüfer Sequence

each college c i C has a capacity q i - the maximum number of students it will admit

Algorithm Design and Analysis

Chapter Load Balancing. Approximation Algorithms. Load Balancing. Load Balancing on 2 Machines. Load Balancing: Greedy Scheduling

Some Minesweeper Configurations

On-line choosability. Grzegorz Gutowski

(67902) Topics in Theory and Complexity Nov 2, Lecture 7

Why Study NP- hardness. NP Hardness/Completeness Overview. P and NP. Scaling 9/3/13. Ron Parr CPS 570. NP hardness is not an AI topic

Generalized Induced Factor Problems

Graph Theory and Complex Networks: An Introduction. Chapter 06: Network analysis

Non-Parametric Statistical Techniques for Computational Forensic Engineering

Near Optimal Solutions

Lecture 30: NP-Hard Problems [Fa 14]

Design and Analysis of ACO algorithms for edge matching problems

NP-complete? NP-hard? Some Foundations of Complexity. Prof. Sven Hartmann Clausthal University of Technology Department of Informatics

Clique coloring B 1 -EPG graphs

Zachary Monaco Georgia College Olympic Coloring: Go For The Gold

Exponential time algorithms for graph coloring

An Improved ACO Algorithm for Multicast Routing

Minimum Bisection is NP-hard on Unit Disk Graphs

IE 680 Special Topics in Production Systems: Networks, Routing and Logistics*

Part 2: Community Detection

Transportation Polytopes: a Twenty year Update

Welcome to... Problem Analysis and Complexity Theory , 3 VU

An Approximation Algorithm for the Unconstrained Traveling Tournament Problem

Fundamentals of algorithms

SIMS 255 Foundations of Software Design. Complexity and NP-completeness

A Fast Algorithm For Finding Hamilton Cycles

Approximation Algorithms

How to Prove a Theorem So No One Else Can Claim It

Examination paper for MA0301 Elementær diskret matematikk

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. #-approximation algorithm.

Lecture 1: Oracle Turing Machines

A number of tasks executing serially or in parallel. Distribute tasks on processors so that minimal execution time is achieved. Optimal distribution

8.1 Min Degree Spanning Tree

On the Relationship between Classes P and NP

The Clar Structure of Fullerenes

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. !-approximation algorithm.

Complexity of the Traveling Tournament Problem

Warshall s Algorithm: Transitive Closure

MATHEMATICAL ENGINEERING TECHNICAL REPORTS. An Improved Approximation Algorithm for the Traveling Tournament Problem

Can linear programs solve NP-hard problems?

Energy Efficient Monitoring in Sensor Networks

COMBINATORIAL PROPERTIES OF THE HIGMAN-SIMS GRAPH. 1. Introduction

Efficient Fault-Tolerant Infrastructure for Cloud Computing

arxiv: v1 [cs.cg] 15 Sep 2014

Graph Theory and Complex Networks: An Introduction. Chapter 06: Network analysis. Contents. Introduction. Maarten van Steen. Version: April 28, 2014

Transcription:

Reductions & NP-completeness as part of Foundations of Computer Science undergraduate course Alex Angelopoulos, NTUA January 22, 2015

Outline Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- 0/1 Integer Programming 2/26 0/1 Integer Programming Vertex Cover 3-colorability Hamilton Path (HP) Traveling Salesman Problem (TSP)

Reducing 3-SAT to 0/1 IP Definition 1 (0/1 IP). Input: an integer matrix C and vector b. Output: decide if there is a 0/1 vector x such that: Cx b. 0/1 IP NP (why?) We choose 3-SAT as our known NP-complete problem and consider the formula: φ = C 1 C 2... C m, literals x 1,..., x n We will construct our m n matrix C : 1, if x j C i c ij = 1, if x j C i 0, otherwise b i = 1 (the number of complemented variables in C i ) Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- 0/1 Integer Programming 3/26

Reducing 3-SAT to 0/1 IP Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- 0/1 Integer Programming 4/26 Note that: Cx b actually means n j=1 c ijx j b i, i. If 3-SAT is satisfiable, then every C i is True. Focus on a line of C and discard the zeros: c ij1 x j1 + c ij2 x j2 + c ij3 x j3 1 #(complemented) = 1x j1 + 1x j2 + 1x j3 1 1x j1 + 1x j2 1x j3 0 1x j1 1x j2 1x j3 1 1x j1 1x j2 1x j3 2 3-SAT P 0/1 IP

Outline Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- Vertex Cover 5/26 0/1 Integer Programming Vertex Cover 3-colorability Hamilton Path (HP) Traveling Salesman Problem (TSP)

From 3-SAT to Vertex Cover Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- Vertex Cover 6/26 Definition 2 (Vertex Cover (VC)). Input: a graph G(V, E). Output: decide if there is a set S V of size S k such that every edge is adjacent to a vertex v S. VC NP (why?) We choose 3-SAT as our known NP-complete problem and consider (again) the formula: φ = C 1 C 2... C m, with literals x 1,..., x n

Intro to gadgets! Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- Vertex Cover 7/26 A gadget is anything (in the context of the target problem) that can help you fix the desired instance... z y y x x x y z z Size of a VC here: 5 = 3 (literals) + 2 (2 clause)

G φ and the if and only if check Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- Vertex Cover 8/26 φ = (x y z) ( y z w) x x y y z z w w z w x y y z ( ) {x, y, z, w} = {T, F, T, T } is a satisfying assignment. See that we need 2 nodes from each clause gadget in order to get a valid VC of size k = n + 2m.

Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- Vertex Cover 9/26 G φ and the if and only if check x x y y z z w w z w x y y z ( ) For a VC we must get: At least 1 vertex of each literal gadget Clause gadget s vetrices cannot cover the literal gadget s edges. At least 2 vertices of each clause gadget (1 cannot cover the triangle). If there is a cover of size n + 2m then the literal gadgets indicate the satisfying assignment!

Outline Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- 3-colorability 10/26 0/1 Integer Programming Vertex Cover 3-colorability Hamilton Path (HP) Traveling Salesman Problem (TSP)

Reducing 3-SAT to 3-COLOR Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- 3-colorability 11/26 Definition 3 (3-COLOR). Input: a graph G(V, E). Output: decide if χ(g) 3? 3-COLOR NP (why?) We choose 3-SAT as our known NP-complete problem and consider (yet again) the formula: φ = C 1 C 2... C m, with literals x 1,..., x n

Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- 3-colorability 12/26 Constructing the graph G φ We ll consider the forumla φ = (x y z) ( y z w). Let s start with the vertices of the literals: for each x i we create v i and v i. In order to dictate an equivalent True/False coloring of v i, v i, we draw all edges v i v i plus we link all v i, v i with a base vertex b. Check that now we have n triangles, all having b in common. b x x y y z z w w

c Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- 3-colorability 13/26 Constructing the graph G φ The gadget: a color-driven or gate C i s literals as input a b c C i evaluation If all a,b,c are colored False, the output vertex has to be False. If a or b or c is True, then the output vertex can also be True.

Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- 3-colorability 14/26 Completing G φ φ = (x y z) ( y z w) t f b x x Let s satisfy φ... χ(g φ ) 3 y y G 1 z z w w G 2

Checking the if and only if Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- 3-colorability 15/26 Now let G φ be 3-colorable. And pay attention to the coloring of u i, ū i t f b 3-SAT P 3-COLOR u1 u1 u2 u2 G1 u3 u3 u4 u4. G2. Since the gadgets output orange, they must each have an orange input. So our true color is the orange, and an assignment that satisfies φ follows the orange u-nodes.

Outline Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- Hamilton Path (HP) 16/26 0/1 Integer Programming Vertex Cover 3-colorability Hamilton Path (HP) Traveling Salesman Problem (TSP)

Reducing 3-SAT to Hamilton Path Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- Hamilton Path (HP) 17/26 Definition 4 (Hamilton Path). Input: graph G. Output: decide whether G allows a path visiting all nodes excatly once. Hamilton Path NP. We can guess n 1 edges and verify if they add up to a Hamilton Path. We need 3 gadgets for this problem..

Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- Hamilton Path (HP) 18/26 Gadgets (1/3) The choice gadget - one per literal T F Actually, the colored edges will become subgraphs that allow a path between the blue nodes. They sure translate to an evaluation True of False for the literal.

Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- Hamilton Path (HP) 19/26 Gadgets (2/3) The consistency gadget - an xor gate A part o a Hamilton Path must either enter and exit this subgraph using both top vertices or both bottom vertices. That exclusive or functionality will be the hint for gadget 3 to prove useful.

Gadgets (3/3) Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- Hamilton Path (HP) 20/26 The constraint gadget - one per clause x 3 x 3 x 1 x 1 C i x 2 x 2 Let s take C i = (x 1 x 2 x 3 ) We must force that the edges (paths) of the triangle are traversed by a Hamilton Path if and only if the corresponding literal is false. Then the clause is True, or else there would be no Hamilton Path!

Constructing the full R(φ) Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- Hamilton Path (HP) 21/26 Let φ = (x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) s t Orange nodes form a clique

Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- Hamilton Path (HP) 22/26 φ is satisfiable R(φ) has a Hamilton Path Let φ = (x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) s t

Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- Hamilton Path (HP) 23/26 R(φ) has a Hamilton Path φ is satisfiable Remember the costraint gadget. If the red edge- xor path belongs to the Hamilton Path, then both green edges do not belong to the path. But this defines a truth assignment, where no clause gets all 3 literals false. t3-sat P Hamilton Path

Outline Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- Traveling Salesman Problem (TSP) 24/26 0/1 Integer Programming Vertex Cover 3-colorability Hamilton Path (HP) Traveling Salesman Problem (TSP)

The Traveling Salesman Problem Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- Traveling Salesman Problem (TSP) 25/26 Definition 5 (TSP). Given a set of n cities and the distance between any two of them, find the shortest tour covering all cities. Definition 6 (TSP (Decision problem)). Input: a complete graph G with weighted edges, budget (target cost) B Output: is there a tour (cycle) visiting every vertex of G with total cost B? Verify that TSP(D) belongs to class NP... We shall use Hamilton Path as ou known NP-complete problem.

Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness- Traveling Salesman Problem (TSP) 26/26 Hamilton Path P TSP(D) Take any instance of Hamilton Path (i.e. any graph G with n vertices) and take a copy of it, Ḡ. Set all edges of Ḡ to have a weight equal to 1. Insert all missing edges of Ḡ with weight 2. To finalize the instance of TSP(D), take B = n + 1. G has a Hamilton Path Ḡ has a tour of cost n + 1... Hamilton Path P TSP(D) Ḡ has a tour of cost n + 1 G has a Hamilton Path...