NP-Completeness Part One

Size: px
Start display at page:

Download "NP-Completeness Part One"

Transcription

1 NP-Completeness Part One

2 Recap from Last Time

3 The Limits of Efficient Computation P NP R

4 P and NP Rresher The class P consists of all problems solvable in terministic polynomial time. The class NP consists of all problems solvable in nonterministic polynomial time. Equivalently, NP consists of all problems for which there is a terministic, polynomial-time verifier for the problem.

5 Reducibility

6 Maximum Matching Given an undirected graph G, a matching in G is a set of edges such that no two edges share an endpoint. A maximum matching is a matching with the largest number of edges.

7 Maximum Matching Given an undirected graph G, a matching in G is a set of edges such that no two edges share an endpoint. A maximum matching is a matching with the largest number of edges.

8 Maximum Matching Given an undirected graph G, a matching in G is a set of edges such that no two edges share an endpoint. A maximum matching is a matching with the largest number of edges. A matching, matching, but but not not a a maximum maximum matching. matching.

9 Maximum Matching Given an undirected graph G, a matching in G is a set of edges such that no two edges share an endpoint. A maximum matching is a matching with the largest number of edges. A maximum maximum matching. matching.

10 Maximum Matching Given an undirected graph G, a matching in G is a set of edges such that no two edges share an endpoint. A maximum matching is a matching with the largest number of edges.

11 Maximum Matching Given an undirected graph G, a matching in G is a set of edges such that no two edges share an endpoint. A maximum matching is a matching with the largest number of edges.

12 Maximum Matching Given an undirected graph G, a matching in G is a set of edges such that no two edges share an endpoint. A maximum matching is a matching with the largest number of edges.

13 Maximum Matching Given an undirected graph G, a matching in G is a set of edges such that no two edges share an endpoint. A maximum matching is a matching with the largest number of edges. Maximum Maximum matchings matchings are are not not necessarily necessarily unique. unique.

14 Maximum Matching Jack Edmonds' paper Paths, Trees, and Flowers gives a polynomial-time algorithm for finding maximum matchings. (This is the same Edmonds as in Cobham- Edmonds Thesis. Using this fact, what other problems can we solve?

15 Domino Tiling

16 Domino Tiling

17 Domino Tiling

18 Domino Tiling

19 Domino Tiling

20 Domino Tiling

21 Solving Domino Tiling

22 Solving Domino Tiling

23 Solving Domino Tiling

24 Solving Domino Tiling

25 Solving Domino Tiling

26 Solving Domino Tiling

27 Solving Domino Tiling

28 Solving Domino Tiling

29 The Setup To termine whether you can place at least k dominoes on a crossword grid, do the following: Convert the grid into a graph: each empty cell is a no, and any two adjacent empty cells have an edge between them. Ask whether that graph has a matching of size k or greater. Return whatever answer you get. Claim: This runs in polynomial time.

30 In Pseudoco boolean canplacekdominos(grid G, int k { } return hasmatching(gridtograph(g, k;

31 Another Example

32 Reachability Consir the following problem: Given an directed graph G and nos s and t in G, is there a path from s to t? As a formal language: REACHABILITY = { G, s, t G is a directed graph, s and t are nos in G, and there's a path from s to t } Theorem: REACHABILITY P. Given that we can solve the reachability problem in polynomial time, what other problems can we solve in polynomial time?

33 Converter Conundrums Suppose that you want to plug your laptop into a projector. Your laptop only has a VGA output, but the projector needs HDMI input. You have a box of connectors that convert various types of input into various types of output (for example, VGA to DVI, DVI to DisplayPort, etc. Question: Can you plug your laptop into the projector?

34 Converter Conundrums Connectors RGB RGB to to USB USB VGA VGA to to DisplayPort DB13W3 DB13W3 to to CATV CATV DisplayPort to to RGB RGB DB13W3 DB13W3 to to HDMI HDMI DVI DVI to to DB13W3 DB13W3 S-Vio S-Vio to to DVI DVI FireWire FireWire to to SDI SDI VGA VGA to to RGB RGB DVI DVI to to DisplayPort USB USB to to S-Vio S-Vio SDI SDI to to HDMI HDMI

35 Converter Conundrums Connectors RGB RGB to to USB USB VGA VGA to to DisplayPort DB13W3 DB13W3 to to CATV CATV DisplayPort to to RGB RGB DB13W3 DB13W3 to to HDMI HDMI DVI DVI to to DB13W3 DB13W3 S-Vio S-Vio to to DVI DVI FireWire FireWire to to SDI SDI VGA VGA to to RGB RGB DVI DVI to to DisplayPort USB USB to to S-Vio S-Vio SDI SDI to to HDMI HDMI VGA RGB USB DisplayPort DB13W3 CATV HDMI X FireWire DVI S-Vio SDI

36 Converter Conundrums VGA RGB USB DisplayPort DB13W3 CATV HDMI X DVI S-Vio FireWire SDI

37 Converter Conundrums VGA RGB USB DisplayPort DB13W3 CATV HDMI X DVI S-Vio FireWire SDI

38 Converter Conundrums VGA RGB USB DisplayPort DB13W3 CATV HDMI X DVI S-Vio FireWire SDI

39 Converter Conundrums Given a a list of plug converters, here's a algorithm for termining whether you can plug your computer into the projector: Create a graph with one no per connector type and an edge from one type of connector to another if there's a converter from the first type to the second. Use the reachability algorithm to see whether you can get from VGA to HDMI. Return whatever the result of that algorithm is. Claim: This runs in polynomial time.

40 In Pseudoco boolean canplugin(list<plug> plugs { } return isreachable(plugstograph(plugs, VGA, HDMI;

41 A Commonality Both of the solutions to our previous problems had the following form: boolean solveproblema(input { return solveproblemb(transform(input; } Important observation: Assuming that we already have a solver for problem B, the only work done here is transforming the input to problem A into an input to problem B. All the hard work is done by the solver for B; we just turn one input into another.

42 Mathematically Moling this Ia

43 Polynomial-Time Reductions Let A and B be languages. A polynomial-time reduction from A to B is a function f : Σ* Σ* such that For any w Σ*, w A iff f(w B. The function f can be computed in polynomial time. What does this mean?

44 Polynomial-Time Reductions If f is a polynomial-time reduction from A to B, then w Σ*. (w A f(w B If you want to know whether w A, you can instead ask whether f(w B. Every w A maps to some f(w B. Every w A maps to some f(w B.

45 Polynomial-Time Reductions If f is a polynomial-time reduction from A to B, then w Σ*. (w A f(w B Σ* Σ*

46 Polynomial-Time Reductions If f is a polynomial-time reduction from A to B, then w Σ*. (w A f(w B YES NO Σ* Σ*

47 Polynomial-Time Reductions If f is a polynomial-time reduction from A to B, then w Σ*. (w A f(w B YES f(w YES NO f(w Σ* Σ* NO

48 Reductions, Programmatically Suppose we have a solver for problem B that's dined in terms of problem A in this specific way: boolean solveproblema(input { return solveproblemb(transform(input; } The reduction from A to B is the function transform in the above setup: it maps yes answers to A to yes answers to B and no answers to A to no answers to B.

49 Reducibility among Problems Suppose that A and B are languages where there's a polynomial-time reduction from A to B. We'll note this by writing A p B You can read this aloud as A polynomialtime reduces to B or A poly-time reduces to B.

50 Reductions and P Theorem: If A p B and B P, then A P. Proof sketch: Show that this pseudoco runs in polynomial time: boolean solveproblema(input { return solveproblemb(transform(input; } Calling transform only takes polynomial time. Since it runs in polynomial time, the transform function can only produce an output that's polynomially larger than its input. Feeding that into a polynomial-time function solveproblemb then only takes polynomial time. Overall, this is a polynomial-time algorithm for A, so A P.

51 Time-Out for Announcements!

52 Please evaluate this course in Axess. Your feedback does make a difference.

53 Your Questions!

54 What's the best way to become a stronger cor? The summer seems like a great time to take advantage of bore the next school year. Seems like classes like CS 107 reward experience which is hard to compete with when you haven't cod for years! Find Find something something fun fun that that you you want want to to work work on, on, then then go go work work on on it. it. You'll You'll have have a a lot lot more more fun fun if if you you actually actually enjoy enjoy what what you're you're doing. doing. And And don't don't worry worry about about CS107. CS107. People People freak freak out out way way too too much much about about that that course. course. You You don't don't need need to to prepare prepare for for months months in in advance advance bore bore taking taking it. it. There There aren't aren't that that many many stunts stunts in in the the course course that that have have a a huge huge headstart headstart over over everyone. everyone. Just Just be be prepared prepared to to put put in in a a cent cent amount amount of of time time and and be be strategic. strategic.

55 I'm sticking around campus for summer any suggestions on what to put on my summer bucket list? Rent Rent a a car car (you (you get get a a discount discount for for being being a a Stanford Stanford stunt stunt and and drive drive up up Skyline Skyline and and walk walk around around the the open open space space preserves. preserves. It's It's beautiful beautiful there. there. Then Then go go to to Pescaro Pescaro and and visit visit a a world-class world-class goat goat dairy dairy farm farm while while eating eating artichoke-garlic artichoke-garlic bread. bread. Go Go to to the the Mission Mission in in SF. SF. Do Do something something totally totally hipsterish hipsterish (Urban (Urban Putt, Putt, Mission Mission Cheese, Cheese, Danlion Danlion Chocolate Chocolate and and something something more more local local (get (get pupusas. pupusas.

56 After your teaser during Wednesday's lecture and 2 days of waiting, we're even more excited for you to speak on something that fascinates you. We'd also like to thank you for answering these questions with such enthusiasm throughout the quarter. Go!

57

58 Back to CS103!

59 Reductions and NP

60 boolean solveproblema(input { return solveproblemb(transform(input; } What What happens if if transform runs runs in in terministic polynomial time, time, but but solveproblemb runs runs in in nonterministic polynomial time? time?

61 Reductions and NP We can reduce problems in NP to one another using polynomial-time reductions. The reduction itself must be computable in terministic polynomial time. The output of that reduction is then fed in as input to a nonterministic, polynomialtime algorithm. Remember the goal of the reduction is to transform the problem, not solve it!

62 A Sample Reduction

63 Satisfiability A propositional logic formula φ is called satisfiable if there is some assignment to its variables that makes it evaluate to true. p q is satisfiable. p p is unsatisfiable. p (q q is satisfiable. An assignment of true and false to the variables of φ that makes it evaluate to true is called a satisfying assignment.

64 SAT The boolean satisfiability problem (SAT is the following: Formally: Given a propositional logic formula φ, is φ satisfiable? SAT = { φ φ is a satisfiable PL formula } Claim: SAT NP. (Do you see why?

65 What other problems can we solve with a solver for SAT?

66 Perfect Matchings A perfect matching in a graph G is a matching where every no is adjacent to some edge in the matching. Claim: We can reduce the problem of termining whether a graph has a perfect matching to the boolean satisfiability problem.

67 Perfect Matchings A perfect matching in a graph G is a matching where every no is adjacent to some edge in the matching. Claim: We can reduce the problem of termining whether a graph has a perfect matching to the boolean satisfiability problem.

68 a b c d e f

69 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching

70 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching p ab ab p ad ad p bc bc p p ce ce p p p

71 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching p ab ab p ad ad p bc bc p p ce ce p p p

72 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p (p (p ab ab p ad ad (p (p ab ab p bc bc (p (p ab ab p (p (p bc bc p (p (p bc bc p ce ce (p (p bc bc p (p (p ce ce p (p (p ad ad p (p (p ad ad p (p (p p (p (p ce ce p (p (p ce ce p (p (p p (p (p p p ab ab p ad ad p bc bc p p ce ce p p p

73 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p (p (p ab ab p ad ad (p (p ab ab p bc bc (p (p ab ab p (p (p bc bc p (p (p bc bc p ce ce (p (p bc bc p (p (p ce ce p (p (p ad ad p (p (p ad ad p (p (p p (p (p ce ce p (p (p ce ce p (p (p p (p (p p p ab ab p ad ad p bc bc p p ce ce p p p

74 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p (p (p ab ab p ad ad (p (p ab ab p bc bc (p (p ab ab p (p (p bc bc p (p (p bc bc p ce ce (p (p bc bc p (p (p ce ce p (p (p ad ad p (p (p ad ad p (p (p p (p (p ce ce p (p (p ce ce p (p (p p (p (p p p ab ab p ad ad p bc bc p p ce ce p p p

75 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p (p (p ab ab p ad ad (p (p ab ab p bc bc (p (p ab ab p (p (p bc bc p (p (p bc bc p ce ce (p (p bc bc p (p (p ce ce p (p (p ad ad p (p (p ad ad p (p (p p (p (p ce ce p (p (p ce ce p (p (p p (p (p p p ab ab p ad ad p bc bc p p ce ce p p p

76 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p (p (p ab ab p ad ad (p (p ab ab p bc bc (p (p ab ab p (p (p bc bc p (p (p bc bc p ce ce (p (p bc bc p (p (p ce ce p (p (p ad ad p (p (p ad ad p (p (p p (p (p ce ce p (p (p ce ce p (p (p p (p (p p p ab ab p ad ad p bc bc p p ce ce p p p

77 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p (p (p ab ab p ad ad (p (p ab ab p bc bc (p (p ab ab p (p (p bc bc p (p (p bc bc p ce ce (p (p bc bc p (p (p ce ce p (p (p ad ad p (p (p ad ad p (p (p p (p (p ce ce p (p (p ce ce p (p (p p (p (p p p ab ab p ad ad p bc bc p p ce ce p p p

78 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p (p (p ab ab p ad ad (p (p ab ab p bc bc (p (p ab ab p (p (p bc bc p (p (p bc bc p ce ce (p (p bc bc p (p (p ce ce p (p (p ad ad p (p (p ad ad p (p (p p (p (p ce ce p (p (p ce ce p (p (p p (p (p p p ab ab p ad ad p bc bc p p ce ce p p p

79 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p (p (p ab ab p ad ad (p (p ab ab p bc bc (p (p ab ab p (p (p bc bc p (p (p bc bc p ce ce (p (p bc bc p (p (p ce ce p (p (p ad ad p (p (p ad ad p (p (p p (p (p ce ce p (p (p ce ce p (p (p p (p (p p p ab ab p ad ad p bc bc p p ce ce p p p

80 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p (p (p ab ab p ad ad (p (p ab ab p bc bc (p (p ab ab p (p (p bc bc p (p (p bc bc p ce ce (p (p bc bc p (p (p ce ce p (p (p ad ad p (p (p ad ad p (p (p p (p (p ce ce p (p (p ce ce p (p (p p (p (p p p ab ab p ad ad p bc bc p p ce ce p p p

81 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p (p (p ab ab p ad ad (p (p ab ab p bc bc (p (p ab ab p (p (p bc bc p (p (p bc bc p ce ce (p (p bc bc p (p (p ce ce p (p (p ad ad p (p (p ad ad p (p (p p (p (p ce ce p (p (p ce ce p (p (p p (p (p p p ab ab p ad ad p bc bc p p ce ce p p p

82 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p (p (p ab ab p ad ad (p (p ab ab p bc bc (p (p ab ab p (p (p bc bc p (p (p bc bc p ce ce (p (p bc bc p (p (p ce ce p (p (p ad ad p (p (p ad ad p (p (p p (p (p ce ce p (p (p ce ce p (p (p p (p (p p p ab ab p ad ad p bc bc p p ce ce p p p

83 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p (p (p ab ab p ad ad (p (p ab ab p bc bc (p (p ab ab p (p (p bc bc p (p (p bc bc p ce ce (p (p bc bc p (p (p ce ce p (p (p ad ad p (p (p ad ad p (p (p p (p (p ce ce p (p (p ce ce p (p (p p (p (p p p ab ab p ad ad p bc bc p p ce ce p p p

84 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p (p (p ab ab p ad ad (p (p ab ab p bc bc (p (p ab ab p (p (p bc bc p (p (p bc bc p ce ce (p (p bc bc p (p (p ce ce p (p (p ad ad p (p (p ad ad p (p (p p (p (p ce ce p (p (p ce ce p (p (p p (p (p p p ab ab p ad ad p bc bc p p ce ce p p p

85 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p ( p ( p ab ab p p ad ad ( p ( p ab ab p p bc bc ( p ( p ab ab p p ( p ( p bc bc p p ( p ( p bc bc p p ce ce ( p ( p bc bc p p ( p ( p ce ce p p ( p ( p ad ad p p ( p ( p ad ad p p ( p ( p p p ( p ( p ce ce p p ( p ( p ce ce p p ( p ( p p p ( p ( p p p p ab ab p ad ad p bc bc p p ce ce p p p

86 a b Notice Notice that that this this formula formula is is the the many-way many-way AND AND of of lots lots of of smaller smaller formulas formulas of of the the form form (l₁ (l₁ l₂ l₂ lₙ lₙ where d e f where each each lₖ lₖ is is either either a variable variable or or its its negation. negation. Each Each lₖ lₖ is is For called each called edge a literal, literal, {u, v}, and and we'll the the introduce multi-way multi-way a propositional OR OR of of literals literals variable is is called called p a uv meaning edge {u, v} is includ clause. clause. in the perfect matching. We To To need satisfy satisfy to enforce this this formula, formula, the following: we we need need to to choose choose truth truth values values so so that that Every no every every is adjacent clause clause has to has at at at least least least one one one edge. true true ( perfect literal. literal. Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p p ab ab (p (p ad ad p p (p (p ce ce p p (p (p p p ad ad ( p ( p ab ab p p ad ad p bc bc ( p ( p ab ab p p bc bc ( p ( p ab ab p p ( p ( p bc bc p p p ( p ( p bc bc p p ce ce ( p ( p bc bc p p ( p ( p ce ce p p p ce ce ( p ( p ad ad p p ( p ( p ad ad p p ( p ( p p p p ( p ( p ce ce p p ( p ( p ce ce p p ( p ( p p p p ( p ( p p p p c

87 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p ( p ( p ab ab p p ad ad ( p ( p ab ab p p bc bc ( p ( p ab ab p p ( p ( p bc bc p p ( p ( p bc bc p p ce ce ( p ( p bc bc p p ( p ( p ce ce p p ( p ( p ad ad p p ( p ( p ad ad p p ( p ( p p p ( p ( p ce ce p p ( p ( p ce ce p p ( p ( p p p ( p ( p p p p ab ab p ad ad p bc bc p p ce ce p p p

88 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p ( p ( p ab ab p p ad ad ( p ( p ab ab p p bc bc ( p ( p ab ab p p ( p ( p bc bc p p ( p ( p bc bc p p ce ce ( p ( p bc bc p p ( p ( p ce ce p p ( p ( p ad ad p p ( p ( p ad ad p p ( p ( p p p ( p ( p ce ce p p ( p ( p ce ce p p ( p ( p p p ( p ( p p p p ab ab p ad ad p bc bc p p ce ce p p p

89 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p ( p ( p ab ab p p ad ad ( p ( p ab ab p p bc bc ( p ( p ab ab p p ( p ( p bc bc p p ( p ( p bc bc p p ce ce ( p ( p bc bc p p ( p ( p ce ce p p ( p ( p ad ad p p ( p ( p ad ad p p ( p ( p p p ( p ( p ce ce p p ( p ( p ce ce p p ( p ( p p p ( p ( p p p p ab ab p ad ad p bc bc p p ce ce p p p

90 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p ( p ( p ab ab p p ad ad ( p ( p ab ab p p bc bc ( p ( p ab ab p p ( p ( p bc bc p p ( p ( p bc bc p p ce ce ( p ( p bc bc p p ( p ( p ce ce p p ( p ( p ad ad p p ( p ( p ad ad p p ( p ( p p p ( p ( p ce ce p p ( p ( p ce ce p p ( p ( p p p ( p ( p p p T p ab ab F p ad ad F p bc bc F p F p ce ce T p T p F p

91 a b c d e f For each edge {u, v}, we'll introduce a propositional variable p uv meaning edge {u, v} is includ in the perfect matching. We need to enforce the following: Every no is adjacent to at least one edge. ( perfect Every no is adjacent to at most one edge. ( matching (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p ( p ( p ab ab p p ad ad ( p ( p ab ab p p bc bc ( p ( p ab ab p p ( p ( p bc bc p p ( p ( p bc bc p p ce ce ( p ( p bc bc p p ( p ( p ce ce p p ( p ( p ad ad p p ( p ( p ad ad p p ( p ( p p p ( p ( p ce ce p p ( p ( p ce ce p p ( p ( p p p ( p ( p p p T p ab ab F p ad ad F p bc bc F p F p ce ce T p T p F p

92 (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p ( p ( p ab ab p p ad ad ( p ( p ab ab p p bc bc ( p ( p ab ab p p ( p ( p bc bc p p ( p ( p bc bc p p ce ce ( p ( p bc bc p p ( p ( p ce ce p p ( p ( p ad ad p p ( p ( p ad ad p p ( p ( p p p ( p ( p ce ce p p ( p ( p ce ce p p ( p ( p p p ( p ( p p p p ab ab p ad ad p bc bc p p ce ce p p p

93 (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p ( p ( p ab ab p p ad ad ( p ( p ab ab p p bc bc ( p ( p ab ab p p ( p ( p bc bc p p ( p ( p bc bc p p ce ce ( p ( p bc bc p p ( p ( p ce ce p p ( p ( p ad ad p p ( p ( p ad ad p p ( p ( p p p ( p ( p ce ce p p ( p ( p ce ce p p ( p ( p p p ( p ( p p p F p ab ab T p ad ad T p bc bc F p F p ce ce F p F p T p

94 (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p ( p ( p ab ab p p ad ad ( p ( p ab ab p p bc bc ( p ( p ab ab p p ( p ( p bc bc p p ( p ( p bc bc p p ce ce ( p ( p bc bc p p ( p ( p ce ce p p ( p ( p ad ad p p ( p ( p ad ad p p ( p ( p p p ( p ( p ce ce p p ( p ( p ce ce p p ( p ( p p p ( p ( p p p F p ab ab T p ad ad T p bc bc F p F p ce ce F p F p T p

95 a b c d e f (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p ( p ( p ab ab p p ad ad ( p ( p ab ab p p bc bc ( p ( p ab ab p p ( p ( p bc bc p p ( p ( p bc bc p p ce ce ( p ( p bc bc p p ( p ( p ce ce p p ( p ( p ad ad p p ( p ( p ad ad p p ( p ( p p p ( p ( p ce ce p p ( p ( p ce ce p p ( p ( p p p ( p ( p p p F p ab ab T p ad ad T p bc bc F p F p ce ce F p F p T p

96 a b c d e f (p (p ab ab p ad ad (p (p ab ab p bc bc p (p (p bc bc p ce ce p (p (p ad ad p p (p (p ce ce p p (p (p p ( p ( p ab ab p p ad ad ( p ( p ab ab p p bc bc ( p ( p ab ab p p ( p ( p bc bc p p ( p ( p bc bc p p ce ce ( p ( p bc bc p p ( p ( p ce ce p p ( p ( p ad ad p p ( p ( p ad ad p p ( p ( p p p ( p ( p ce ce p p ( p ( p ce ce p p ( p ( p p p ( p ( p p p F p ab ab T p ad ad T p bc bc F p F p ce ce F p F p T p

97 The Reduction Suppose we have a graph with n nos. For each of the n nos, we introduce a clause of at most n literals to force each no to be adjacent to at least one chosen edge. Total size: O(n 2 For each of the n nos, we introduce O(n 2 clauses with two literals each to force each no to be adjacent to at most one chosen edge. Total size: O(n 3 Total size of the generated formula: at most O(n 3. Unsubstantiated but true claim: This can be computed in polynomial time.

98 The Reduction boolean hasperfectmatching(graph G { return issatisfiable(graphtoformula(g; }

99 Reductions and NP Theorem: If A p B and B NP, then A NP. Proof sketch: Show that this pseudoco runs in nonterministic polynomial time: boolean solveproblema(input { return solveproblemb(transform(input; } Calling transform only takes polynomial time. The transform function can only produce an output that's polynomially larger than its input. Feeding that into a polynomial-time function solveproblemb then only takes nonterministic polynomial time. Overall, this is a nonterministic polynomial-time algorithm for A, so A NP.

100 Reducibility, Summarized A polynomial-time reduction is a way of transforming inputs to problem A into inputs to problem B that preserves the correct answer. If there is a polynomial-time reduction from A to B, we note this by writing A p B. Two major theorems: Theorem: If B P and A p B, then A P. Theorem: If B NP and A p B, then A NP.

101 NP-Hardness and NP-Completeness

102 Polynomial-Time Reductions If L 1 P L 2 and L 2 P, then L 1 P. If L 1 P L 2 and L 2 NP, then L 1 NP. P

103 Polynomial-Time Reductions If L 1 P L 2 and L 2 P, then L 1 P. If L 1 P L 2 and L 2 NP, then L 1 NP. P

104 Polynomial-Time Reductions If L 1 P L 2 and L 2 P, then L 1 P. If L 1 P L 2 and L 2 NP, then L 1 NP. P

105 Polynomial-Time Reductions If L 1 P L 2 and L 2 P, then L 1 P. If L 1 P L 2 and L 2 NP, then L 1 NP. P

106 Polynomial-Time Reductions If L 1 P L 2 and L 2 P, then L 1 P. If L 1 P L 2 and L 2 NP, then L 1 NP. P NP

107 Polynomial-Time Reductions If L 1 P L 2 and L 2 P, then L 1 P. If L 1 P L 2 and L 2 NP, then L 1 NP. P NP

108 Polynomial-Time Reductions If L 1 P L 2 and L 2 P, then L 1 P. If L 1 P L 2 and L 2 NP, then L 1 NP. P NP

109 NP-Hardness A language L is called NP-hard if for every L' NP, we have L' P L. A language in L is called NP-complete iff L is NP-hard and L NP. The class NPC is the set of NP-complete problems. NP P

110 NP-Hardness A language L is called NP-hard if for every L' NP, we have L' P L. A language in L is called NP-complete iff L is NP-hard and L NP. The class NPC is the set of NP-complete problems. NP NP-Hard P

111 NP-Hardness A language L is called NP-hard if for every L' NP, we have L' P L. A language in L is called NP-complete iff L is NP-hard and L NP. The class NPC is the set of NP-complete problems. NP NP-Hard P

112 NP-Hardness A language L is called NP-hard if for every L' NP, we have L' P L. Intuitively: L has has to to be be at at least least as as hard as every problem in NP, since an an algorithm for for L can can be be used used to to ci all all problems in in NP. NP. A language in L is hard called as NP-complete every problem iff L is in NP-hard NP, since and L NP. The class NPC is the set of NP-complete problems. NP NP-Hard P

113 NP-Hardness A language L is called NP-hard if for every L' NP, we have L' P L. A language in L is called NP-complete iff L is NP-hard and L NP. The class NPC is the set of NP-complete problems. NP NP-Hard P

114 NP-Hardness A language L is called NP-hard if for every L' NP, we have L' P L. A language in L is called NP-complete iff L What's What's is NP-hard in in here? here? and L NP. The class NPC is the set of NP-complete problems. NP NP-Hard P

115 NP-Hardness A language L is called NP-hard if for every L' NP, we have L' P L. A language in L is called NP-complete if L is NP-hard and L NP. The class NPC is the set of NP-complete problems. NP NP-Hard P

116 NP-Hardness A language L is called NP-hard if for every L' NP, we have L' P L. A language in L is called NP-complete if L is NP-hard and L NP. The class NPC is the set of NP-complete problems. NP NPC NP-Hard P

117 The Tantalizing Truth Theorem: If any NP-complete language is in P, then P = NP. Proof: Suppose that L is NP-complete and L P. Now consir any arbitrary NP problem X. Since L is NP-complete, we know that X p L. Since L P and X p L, we see that X P. Since our choice of X was arbitrary, this means that NP P, so P = NP.

118 The Tantalizing Truth Theorem: If any NP-complete language is in P, then P = NP. Proof: Suppose that L is NP-complete and L P. Now consir any arbitrary NP problem X. Since L is NP-complete, we know that X p L. Since L P and X p L, we see that X P. Since our choice of X was arbitrary, this means that NP P, so P = NP. NPC NP P

119 The Tantalizing Truth Theorem: If any NP-complete language is in P, then P = NP. Proof: Suppose that L is NP-complete and L P. Now consir any arbitrary NP problem X. Since L is NP-complete, we know that X p L. Since L P and X p L, we see that X P. Since our choice of X was arbitrary, this means that NP P, so P = NP. NPC NP P

120 The Tantalizing Truth Theorem: If any NP-complete language is in P, then P = NP. Proof: Suppose that L is NP-complete and L P. Now consir any arbitrary NP problem X. Since L is NP-complete, we know that X p L. Since L P and X p L, we see that X P. Since our choice of X was arbitrary, this means that NP P, so P = NP. NPC NP P

121 The Tantalizing Truth Theorem: If any NP-complete language is in P, then P = NP. Proof: Suppose that L is NP-complete and L P. Now consir any arbitrary NP problem X. Since L is NP-complete, we know that X p L. Since L P and X p L, we see that X P. Since our choice of X was arbitrary, this means that NP P, so P = NP. P = NP

122 The Tantalizing Truth Theorem: If any NP-complete language is in P, then P = NP. Proof: Suppose that L is NP-complete and L P. Now consir any arbitrary NP problem X. Since L is NP-complete, we know that X p L. Since L P and X p L, we see that X P. Since our choice of X was arbitrary, this means that NP P, so P = NP. P = NP

123 The Tantalizing Truth Theorem: If any NP-complete language is not in P, then P NP. Proof: Suppose that L is an NP-complete language not in P. Since L is NP-complete, we know that L NP. Therore, we know that L NP and L P, so P NP. NP P NPC

124 A Feel for NP-Completeness If a problem is NP-complete, then unr the assumption that P NP, there cannot be an ficient algorithm for it. In a sense, NP-complete problems are the harst problems in NP. All known NP-complete problems are enormously hard to solve: All known algorithms for NP-complete problems run in worst-case exponential time. Most algorithms for NP-complete problems are infeasible for reasonably-sized inputs.

125 How do we even know NP-complete problems exist in the first place?

126 Satisfiability A propositional logic formula φ is called satisfiable if there is some assignment to its variables that makes it evaluate to true. p q is satisfiable. p p is unsatisfiable. p (q q is satisfiable. An assignment of true and false to the variables of φ that makes it evaluate to true is called a satisfying assignment.

127 SAT The boolean satisfiability problem (SAT is the following: Formally: Given a propositional logic formula φ, is φ satisfiable? SAT = { φ φ is a satisfiable PL formula }

128 Theorem (Cook-Levin: SAT is NP-complete. Proof: Take CS154!

129 Finding Additional NP-Complete Problems

130 NP-Completeness Theorem: Let L₁ and L₂ be languages. If L₁ P L₂ and L₁ is NP-hard, then L₂ is NP-hard. Theorem: Let L₁ and L₂ be languages where L₁ NPC and L₂ NP. If L₁ P L₂, then L₂ NPC.

131 NP-Completeness Theorem: Let L₁ and L₂ be languages. If L₁ P L₂ and L₁ is NP-hard, then L₂ is NP-hard. Theorem: Let L₁ and L₂ be languages where L₁ NPC and L₂ NP. If L₁ P L₂, then L₂ NPC. NP P NPC

132 NP-Completeness Theorem: Let L₁ and L₂ be languages. If L₁ P L₂ and L₁ is NP-hard, then L₂ is NP-hard. Theorem: Let L₁ and L₂ be languages where L₁ NPC and L₂ NP. If L₁ P L₂, then L₂ NPC. NP P NPC

133 NP-Completeness Theorem: Let L₁ and L₂ be languages. If L₁ P L₂ and L₁ is NP-hard, then L₂ is NP-hard. Theorem: Let L₁ and L₂ be languages where L₁ NPC and L₂ NP. If L₁ P L₂, then L₂ NPC. NP P NPC

134 NP-Completeness Theorem: Let L₁ and L₂ be languages. If L₁ P L₂ and L₁ is NP-hard, then L₂ is NP-hard. Theorem: Let L₁ and L₂ be languages where L₁ NPC and L₂ NP. If L₁ P L₂, then L₂ NPC. NP P NPC

135 NP-Completeness Theorem: Let L₁ and L₂ be languages. If L₁ P L₂ and L₁ is NP-hard, then L₂ is NP-hard. Theorem: Let L₁ and L₂ be languages where L₁ NPC and L₂ NP. If L₁ P L₂, then L₂ NPC. NP P NPC

136 NP-Completeness Theorem: Let L₁ and L₂ be languages. If L₁ P L₂ and L₁ is NP-hard, then L₂ is NP-hard. Theorem: Let L₁ and L₂ be languages where L₁ NPC and L₂ NP. If L₁ P L₂, then L₂ NPC. NP P NPC

NP-Completeness Part One

NP-Completeness Part One NP-Completeness Part One Recap from Last Time The Limits of Efficient Computation P NP R P and NP Rresher The class P consists of all problems cidable in polynomial time. The class NP consists of all problems

More information

NP-Completeness Part I

NP-Completeness Part I NP-Completeness Part I Outline for Today Recap from Last Time Welcome back from break! Let's make sure we're all on the same page here. Polynomial-Time Reducibility Connecting problems together. NP-Completeness

More information

NP-Completeness Part One

NP-Completeness Part One NP-Completeness Part One Recap from Last Time The Limits of Efficient Computation P NP R P and NP Refresher The class P consists of all problems decidable in polynomial time. The class NP consists of all

More information

Complexity Theory Part Two

Complexity Theory Part Two Complexity Theory Part Two Recap from Last Time The Complexity Class P The complexity class P (for polynomial time) contains all problems that can be solved in polynomial time. Formally: P = { L There

More information

Complexity Theory Part Two

Complexity Theory Part Two Complexity Theory Part Two Recap from Last Time The Cobham-Edmonds Thesis A language L can be decided eficiently if there is a TM that decides it in polynomial time. Equivalently, L can be decided eficiently

More information

Complexity Theory Part Two

Complexity Theory Part Two Complexity Theory Part Two Recap from Last Time The Cobham-Edmonds Thesis A language L can be decided efficiently if there is a TM that decides it in polynomial time. Equivalently, L can be decided efficiently

More information

Complexity Theory Part Two

Complexity Theory Part Two Complexity Theory Part Two Recap from Last Time The Cobham-Edmonds Thesis A language L can be decided efficiently if there is a TM that decides it in polynomial time. Equivalently, L can be decided efficiently

More information

NP-Completeness Part One

NP-Completeness Part One NP-Completeness Part One Recap from Last Time Regular Languages CFLs R RE All Languages Regular Languages CFLs R RE All Languages Regular Languages CFLs Efficiently Decidable Languages R Undecidable Languages

More information

NP-Completeness Part II

NP-Completeness Part II NP-Completeness Part II Please evaluate this course on Axess. Your comments really do make a difference. Announcements Problem Set 8 due tomorrow at 12:50PM sharp with one late day. Problem Set 9 out,

More information

NP-Completeness Part II

NP-Completeness Part II NP-Completeness Part II Outline for Today Recap from Last Time What is NP-completeness again, anyway? 3SAT A simple, canonical NP-complete problem. Independent Sets Discovering a new NP-complete problem.

More information

Recap from Last Time

Recap from Last Time NP-Completeness Recap from Last Time Analyzing NTMs When discussing deterministic TMs, the notion of time complexity is (reasonably) straightforward. Recall: One way of thinking about nondeterminism is

More information

Announcements. Friday Four Square! Problem Set 8 due right now. Problem Set 9 out, due next Friday at 2:15PM. Did you lose a phone in my office?

Announcements. Friday Four Square! Problem Set 8 due right now. Problem Set 9 out, due next Friday at 2:15PM. Did you lose a phone in my office? N P NP Completeness Announcements Friday Four Square! Today at 4:15PM, outside Gates. Problem Set 8 due right now. Problem Set 9 out, due next Friday at 2:15PM. Explore P, NP, and their connection. Did

More information

Complexity Theory Part II

Complexity Theory Part II Complexity Theory Part II Time Complexity The time complexity of a TM M is a function denoting the worst-case number of steps M takes on any input of length n. By convention, n denotes the length of the

More information

Recap from Last Time

Recap from Last Time P and NP Recap from Last Time The Limits of Decidability In computability theory, we ask the question What problems can be solved by a computer? In complexity theory, we ask the question What problems

More information

Topics in Complexity Theory

Topics in Complexity Theory Topics in Complexity Theory Announcements Final exam this Friday from 12:15PM-3:15PM Please let us know immediately after lecture if you want to take the final at an alternate time and haven't yet told

More information

NP-Completeness Part II

NP-Completeness Part II NP-Completeness Part II Recap from Last Time NP-Hardness A language L is called NP-hard iff for every L' NP, we have L' P L. A language in L is called NP-complete iff L is NP-hard and L NP. The class NPC

More information

Friday Four Square! Today at 4:15PM, Outside Gates

Friday Four Square! Today at 4:15PM, Outside Gates P and NP Friday Four Square! Today at 4:15PM, Outside Gates Recap from Last Time Regular Languages DCFLs CFLs Efficiently Decidable Languages R Undecidable Languages Time Complexity A step of a Turing

More information

COP 4531 Complexity & Analysis of Data Structures & Algorithms

COP 4531 Complexity & Analysis of Data Structures & Algorithms COP 4531 Complexity & Analysis of Data Structures & Algorithms Lecture 18 Reductions and NP-completeness Thanks to Kevin Wayne and the text authors who contributed to these slides Classify Problems According

More information

Intro to Theory of Computation

Intro to Theory of Computation Intro to Theory of Computation LECTURE 25 Last time Class NP Today Polynomial-time reductions Adam Smith; Sofya Raskhodnikova 4/18/2016 L25.1 The classes P and NP P is the class of languages decidable

More information

Algorithms Design & Analysis. Approximation Algorithm

Algorithms Design & Analysis. Approximation Algorithm Algorithms Design & Analysis Approximation Algorithm Recap External memory model Merge sort Distribution sort 2 Today s Topics Hard problem Approximation algorithms Metric traveling salesman problem A

More information

SAT, NP, NP-Completeness

SAT, NP, NP-Completeness CS 473: Algorithms, Spring 2018 SAT, NP, NP-Completeness Lecture 22 April 13, 2018 Most slides are courtesy Prof. Chekuri Ruta (UIUC) CS473 1 Spring 2018 1 / 57 Part I Reductions Continued Ruta (UIUC)

More information

Essential facts about NP-completeness:

Essential facts about NP-completeness: CMPSCI611: NP Completeness Lecture 17 Essential facts about NP-completeness: Any NP-complete problem can be solved by a simple, but exponentially slow algorithm. We don t have polynomial-time solutions

More information

Announcements. Problem Set 7 graded; will be returned at end of lecture. Unclaimed problem sets and midterms moved!

Announcements. Problem Set 7 graded; will be returned at end of lecture. Unclaimed problem sets and midterms moved! N P NP Announcements Problem Set 7 graded; will be returned at end of lecture. Unclaimed problem sets and midterms moved! Now in cabinets in the Gates open area near the drop-off box. The Complexity Class

More information

CS103 Handout 22 Fall 2012 November 30, 2012 Problem Set 9

CS103 Handout 22 Fall 2012 November 30, 2012 Problem Set 9 CS103 Handout 22 Fall 2012 November 30, 2012 Problem Set 9 In this final problem set of the quarter, you will explore the limits of what can be computed efficiently. What problems do we believe are computationally

More information

Topics in Complexity

Topics in Complexity Topics in Complexity Please evaluate this course on Axess! Your feedback really does make a difference. Applied Complexity Theory Complexity theory has enormous practical relevance across various domains

More information

Polynomial-Time Reductions

Polynomial-Time Reductions Reductions 1 Polynomial-Time Reductions Classify Problems According to Computational Requirements Q. Which problems will we be able to solve in practice? A working definition. [von Neumann 1953, Godel

More information

Approximation Algorithms

Approximation Algorithms Approximation Algorithms Announcements Problem Set 9 due right now. Final exam this Monday, Hewlett 200 from 12:15PM- 3:15PM Please let us know immediately after lecture if you want to take the final at

More information

CS 583: Algorithms. NP Completeness Ch 34. Intractability

CS 583: Algorithms. NP Completeness Ch 34. Intractability CS 583: Algorithms NP Completeness Ch 34 Intractability Some problems are intractable: as they grow large, we are unable to solve them in reasonable time What constitutes reasonable time? Standard working

More information

Computational Intractability 2010/4/15. Lecture 2

Computational Intractability 2010/4/15. Lecture 2 Computational Intractability 2010/4/15 Professor: David Avis Lecture 2 Scribe:Naoki Hatta 1 P and NP 1.1 Definition of P and NP Decision problem it requires yes/no answer. Example: X is a set of strings.

More information

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015 CS 374: Algorithms & Models of Computation, Spring 2015 NP Completeness Lecture 23 November 19, 2015 Chandra & Lenny (UIUC) CS374 1 Spring 2015 1 / 37 Part I NP-Completeness Chandra & Lenny (UIUC) CS374

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms Design and Analysis of Algorithms CSE 5311 Lecture 25 NP Completeness Junzhou Huang, Ph.D. Department of Computer Science and Engineering CSE5311 Design and Analysis of Algorithms 1 NP-Completeness Some

More information

Complexity Theory Part I

Complexity Theory Part I Complexity Theory Part I Outline for Today Recap from Last Time Reviewing Verifiers Nondeterministic Turing Machines What does nondeterminism mean in the context of TMs? And just how powerful are NTMs?

More information

Chapter 2. Reductions and NP. 2.1 Reductions Continued The Satisfiability Problem (SAT) SAT 3SAT. CS 573: Algorithms, Fall 2013 August 29, 2013

Chapter 2. Reductions and NP. 2.1 Reductions Continued The Satisfiability Problem (SAT) SAT 3SAT. CS 573: Algorithms, Fall 2013 August 29, 2013 Chapter 2 Reductions and NP CS 573: Algorithms, Fall 2013 August 29, 2013 2.1 Reductions Continued 2.1.1 The Satisfiability Problem SAT 2.1.1.1 Propositional Formulas Definition 2.1.1. Consider a set of

More information

NP and Computational Intractability

NP and Computational Intractability NP and Computational Intractability 1 Polynomial-Time Reduction Desiderata'. Suppose we could solve X in polynomial-time. What else could we solve in polynomial time? don't confuse with reduces from Reduction.

More information

Complexity Theory Part I

Complexity Theory Part I Complexity Theory Part I Problem Problem Set Set 77 due due right right now now using using a late late period period The Limits of Computability EQ TM EQ TM co-re R RE L D ADD L D HALT A TM HALT A TM

More information

NP and Computational Intractability

NP and Computational Intractability NP and Computational Intractability 1 Review Basic reduction strategies. Simple equivalence: INDEPENDENT-SET P VERTEX-COVER. Special case to general case: VERTEX-COVER P SET-COVER. Encoding with gadgets:

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 26 Computational Intractability Polynomial Time Reductions Sofya Raskhodnikova S. Raskhodnikova; based on slides by A. Smith and K. Wayne L26.1 What algorithms are

More information

Introduction to Computational Complexity

Introduction to Computational Complexity Introduction to Computational Complexity Tandy Warnow October 30, 2018 CS 173, Introduction to Computational Complexity Tandy Warnow Overview Topics: Solving problems using oracles Proving the answer to

More information

CSE 135: Introduction to Theory of Computation NP-completeness

CSE 135: Introduction to Theory of Computation NP-completeness CSE 135: Introduction to Theory of Computation NP-completeness Sungjin Im University of California, Merced 04-15-2014 Significance of the question if P? NP Perhaps you have heard of (some of) the following

More information

NP-Completeness. Until now we have been designing algorithms for specific problems

NP-Completeness. Until now we have been designing algorithms for specific problems NP-Completeness 1 Introduction Until now we have been designing algorithms for specific problems We have seen running times O(log n), O(n), O(n log n), O(n 2 ), O(n 3 )... We have also discussed lower

More information

NP-Complete Reductions 1

NP-Complete Reductions 1 x x x 2 x 2 x 3 x 3 x 4 x 4 CS 4407 2 22 32 Algorithms 3 2 23 3 33 NP-Complete Reductions Prof. Gregory Provan Department of Computer Science University College Cork Lecture Outline x x x 2 x 2 x 3 x 3

More information

1. Introduction Recap

1. Introduction Recap 1. Introduction Recap 1. Tractable and intractable problems polynomial-boundness: O(n k ) 2. NP-complete problems informal definition 3. Examples of P vs. NP difference may appear only slightly 4. Optimization

More information

NP-Completeness Review

NP-Completeness Review CS124 NP-Completeness Review Where We Are Headed Up to this point, we have generally assumed that if we were given a problem, we could find a way to solve it. Unfortunately, as most of you know, there

More information

CS154, Lecture 13: P vs NP

CS154, Lecture 13: P vs NP CS154, Lecture 13: P vs NP The EXTENDED Church-Turing Thesis Everyone s Intuitive Notion of Efficient Algorithms Polynomial-Time Turing Machines More generally: TM can simulate every reasonable model of

More information

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions Summary of the previous lecture Recall that we mentioned the following topics: P: is the set of decision problems (or languages) that are solvable in polynomial time. NP: is the set of decision problems

More information

CS21 Decidability and Tractability

CS21 Decidability and Tractability CS21 Decidability and Tractability Lecture 18 February 16, 2018 February 16, 2018 CS21 Lecture 18 1 Outline the complexity class NP 3-SAT is NP-complete NP-complete problems: independent set, vertex cover,

More information

Mathematical Logic Part Three

Mathematical Logic Part Three Mathematical Logic Part hree riday our Square! oday at 4:15PM, Outside Gates Announcements Problem Set 3 due right now. Problem Set 4 goes out today. Checkpoint due Monday, October 22. Remainder due riday,

More information

NP-Complete problems

NP-Complete problems NP-Complete problems NP-complete problems (NPC): A subset of NP. If any NP-complete problem can be solved in polynomial time, then every problem in NP has a polynomial time solution. NP-complete languages

More information

9. PSPACE 9. PSPACE. PSPACE complexity class quantified satisfiability planning problem PSPACE-complete

9. PSPACE 9. PSPACE. PSPACE complexity class quantified satisfiability planning problem PSPACE-complete Geography game Geography. Alice names capital city c of country she is in. Bob names a capital city c' that starts with the letter on which c ends. Alice and Bob repeat this game until one player is unable

More information

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

6.080 / Great Ideas in Theoretical Computer Science Spring 2008 MIT OpenCourseWare http://ocw.mit.edu 6.080 / 6.089 Great Ideas in Theoretical Computer Science Spring 2008 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.

More information

9. PSPACE. PSPACE complexity class quantified satisfiability planning problem PSPACE-complete

9. PSPACE. PSPACE complexity class quantified satisfiability planning problem PSPACE-complete 9. PSPACE PSPACE complexity class quantified satisfiability planning problem PSPACE-complete Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley Copyright 2013 Kevin Wayne http://www.cs.princeton.edu/~wayne/kleinberg-tardos

More information

CS21 Decidability and Tractability

CS21 Decidability and Tractability CS21 Decidability and Tractability Lecture 20 February 23, 2018 February 23, 2018 CS21 Lecture 20 1 Outline the complexity class NP NP-complete probelems: Subset Sum NP-complete problems: NAE-3-SAT, max

More information

Comp487/587 - Boolean Formulas

Comp487/587 - Boolean Formulas Comp487/587 - Boolean Formulas 1 Logic and SAT 1.1 What is a Boolean Formula Logic is a way through which we can analyze and reason about simple or complicated events. In particular, we are interested

More information

NP-Complete Problems. More reductions

NP-Complete Problems. More reductions NP-Complete Problems More reductions Definitions P: problems that can be solved in polynomial time (typically in n, size of input) on a deterministic Turing machine Any normal computer simulates a DTM

More information

Complexity Theory Part One

Complexity Theory Part One Complexity Theory Part One Complexity Theory It may be that since one is customarily concerned with existence, [ ] finiteness, and so forth, one is not inclined to take seriously the question of the existence

More information

Lecture Notes Each circuit agrees with M on inputs of length equal to its index, i.e. n, x {0, 1} n, C n (x) = M(x).

Lecture Notes Each circuit agrees with M on inputs of length equal to its index, i.e. n, x {0, 1} n, C n (x) = M(x). CS 221: Computational Complexity Prof. Salil Vadhan Lecture Notes 4 February 3, 2010 Scribe: Jonathan Pines 1 Agenda P-/NP- Completeness NP-intermediate problems NP vs. co-np L, NL 2 Recap Last time, we

More information

A brief introduction to Logic. (slides from

A brief introduction to Logic. (slides from A brief introduction to Logic (slides from http://www.decision-procedures.org/) 1 A Brief Introduction to Logic - Outline Propositional Logic :Syntax Propositional Logic :Semantics Satisfiability and validity

More information

Summer School on Introduction to Algorithms and Optimization Techniques July 4-12, 2017 Organized by ACMU, ISI and IEEE CEDA.

Summer School on Introduction to Algorithms and Optimization Techniques July 4-12, 2017 Organized by ACMU, ISI and IEEE CEDA. Summer School on Introduction to Algorithms and Optimization Techniques July 4-12, 2017 Organized by ACMU, ISI and IEEE CEDA NP Completeness Susmita Sur-Kolay Advanced Computing and Microelectronics Unit

More information

NP-Complete Reductions 2

NP-Complete Reductions 2 x 1 x 1 x 2 x 2 x 3 x 3 x 4 x 4 12 22 32 CS 447 11 13 21 23 31 33 Algorithms NP-Complete Reductions 2 Prof. Gregory Provan Department of Computer Science University College Cork 1 Lecture Outline NP-Complete

More information

Mathematical Logic Part Three

Mathematical Logic Part Three Mathematical Logic Part Three Recap from Last Time What is First-Order Logic? First-order logic is a logical system for reasoning about properties of objects. Augments the logical connectives from propositional

More information

Notes for Lecture 21

Notes for Lecture 21 U.C. Berkeley CS170: Intro to CS Theory Handout N21 Professor Luca Trevisan November 20, 2001 Notes for Lecture 21 1 Tractable and Intractable Problems So far, almost all of the problems that we have studied

More information

SAT, Coloring, Hamiltonian Cycle, TSP

SAT, Coloring, Hamiltonian Cycle, TSP 1 SAT, Coloring, Hamiltonian Cycle, TSP Slides by Carl Kingsford Apr. 28, 2014 Sects. 8.2, 8.7, 8.5 2 Boolean Formulas Boolean Formulas: Variables: x 1, x 2, x 3 (can be either true or false) Terms: t

More information

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch] NP-Completeness Andreas Klappenecker [based on slides by Prof. Welch] 1 Prelude: Informal Discussion (Incidentally, we will never get very formal in this course) 2 Polynomial Time Algorithms Most of the

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURES 30-31 NP-completeness Definition NP-completeness proof for CIRCUIT-SAT Adam Smith 11/3/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova,

More information

Lecture 15 - NP Completeness 1

Lecture 15 - NP Completeness 1 CME 305: Discrete Mathematics and Algorithms Instructor: Professor Aaron Sidford (sidford@stanford.edu) February 29, 2018 Lecture 15 - NP Completeness 1 In the last lecture we discussed how to provide

More information

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k.

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k. Complexity Theory Problems are divided into complexity classes. Informally: So far in this course, almost all algorithms had polynomial running time, i.e., on inputs of size n, worst-case running time

More information

More NP-Complete Problems

More NP-Complete Problems CS 473: Algorithms, Spring 2018 More NP-Complete Problems Lecture 23 April 17, 2018 Most slides are courtesy Prof. Chekuri Ruta (UIUC) CS473 1 Spring 2018 1 / 57 Recap NP: languages/problems that have

More information

Mathematical Logic Part One

Mathematical Logic Part One Mathematical Logic Part One Question: How do we formalize the defnitions and reasoning we use in our proofs? Where We're Going Propositional Logic (Today) Basic logical connectives. Truth tables. Logical

More information

NP-Hardness reductions

NP-Hardness reductions NP-Hardness reductions Definition: P is the class of problems that can be solved in polynomial time, that is n c for a constant c Roughly, if a problem is in P then it's easy, and if it's not in P then

More information

NP Complete Problems. COMP 215 Lecture 20

NP Complete Problems. COMP 215 Lecture 20 NP Complete Problems COMP 215 Lecture 20 Complexity Theory Complexity theory is a research area unto itself. The central project is classifying problems as either tractable or intractable. Tractable Worst

More information

CS154, Lecture 13: P vs NP

CS154, Lecture 13: P vs NP CS154, Lecture 13: P vs NP The EXTENDED Church-Turing Thesis Everyone s Intuitive Notion of Efficient Algorithms Polynomial-Time Turing Machines More generally: TM can simulate every reasonable model of

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION "Winter" 2018 http://cseweb.ucsd.edu/classes/wi18/cse105-ab/ Today's learning goals Sipser Ch 7 Define NP-completeness Give examples of NP-complete problems Use polynomial-time

More information

Chapter 9. PSPACE: A Class of Problems Beyond NP. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

Chapter 9. PSPACE: A Class of Problems Beyond NP. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved. Chapter 9 PSPACE: A Class of Problems Beyond NP Slides by Kevin Wayne. Copyright @ 2005 Pearson-Addison Wesley. All rights reserved. 1 Geography Game Geography. Alice names capital city c of country she

More information

1.1 P, NP, and NP-complete

1.1 P, NP, and NP-complete CSC5160: Combinatorial Optimization and Approximation Algorithms Topic: Introduction to NP-complete Problems Date: 11/01/2008 Lecturer: Lap Chi Lau Scribe: Jerry Jilin Le This lecture gives a general introduction

More information

Knowledge base (KB) = set of sentences in a formal language Declarative approach to building an agent (or other system):

Knowledge base (KB) = set of sentences in a formal language Declarative approach to building an agent (or other system): Logic Knowledge-based agents Inference engine Knowledge base Domain-independent algorithms Domain-specific content Knowledge base (KB) = set of sentences in a formal language Declarative approach to building

More information

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

NP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness Lecture 19 NP-Completeness I 19.1 Overview In the past few lectures we have looked at increasingly more expressive problems that we were able to solve using efficient algorithms. In this lecture we introduce

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 31 P and NP Self-reducibility NP-completeness Adam Smith 12/1/2008 S. Raskhodnikova; based on slides by K. Wayne Central ideas we ll cover Poly-time as feasible most

More information

NP-Completeness. Algorithmique Fall semester 2011/12

NP-Completeness. Algorithmique Fall semester 2011/12 NP-Completeness Algorithmique Fall semester 2011/12 1 What is an Algorithm? We haven t really answered this question in this course. Informally, an algorithm is a step-by-step procedure for computing a

More information

Lecture 4: NP and computational intractability

Lecture 4: NP and computational intractability Chapter 4 Lecture 4: NP and computational intractability Listen to: Find the longest path, Daniel Barret What do we do today: polynomial time reduction NP, co-np and NP complete problems some examples

More information

CS Fall 2011 P and NP Carola Wenk

CS Fall 2011 P and NP Carola Wenk CS3343 -- Fall 2011 P and NP Carola Wenk Slides courtesy of Piotr Indyk with small changes by Carola Wenk 11/29/11 CS 3343 Analysis of Algorithms 1 We have seen so far Algorithms for various problems Running

More information

P vs. NP. Data Structures and Algorithms CSE AU 1

P vs. NP. Data Structures and Algorithms CSE AU 1 P vs. NP Data Structures and Algorithms CSE 373-18AU 1 Goals for today Define P, NP, and NP-complete Explain the P vs. NP problem -why it s the biggest open problem in CS. -And what to do when a problem

More information

NP and NP-Completeness

NP and NP-Completeness 0/2/206 Algorithms NP-Completeness 7- Algorithms NP-Completeness 7-2 Efficient Certification NP and NP-Completeness By a solution of a decision problem X we understand a certificate witnessing that an

More information

CS154, Lecture 15: Cook-Levin Theorem SAT, 3SAT

CS154, Lecture 15: Cook-Levin Theorem SAT, 3SAT CS154, Lecture 15: Cook-Levin Theorem SAT, 3SAT Definition: A language B is NP-complete if: 1. B NP 2. Every A in NP is poly-time reducible to B That is, A P B When this is true, we say B is NP-hard On

More information

8.1 Polynomial-Time Reductions. Chapter 8. NP and Computational Intractability. Classify Problems

8.1 Polynomial-Time Reductions. Chapter 8. NP and Computational Intractability. Classify Problems Chapter 8 8.1 Polynomial-Time Reductions NP and Computational Intractability Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 Classify Problems According to Computational

More information

NP Completeness and Approximation Algorithms

NP Completeness and Approximation Algorithms Chapter 10 NP Completeness and Approximation Algorithms Let C() be a class of problems defined by some property. We are interested in characterizing the hardest problems in the class, so that if we can

More information

8. INTRACTABILITY I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley. Last updated on 2/6/18 2:16 AM

8. INTRACTABILITY I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley. Last updated on 2/6/18 2:16 AM 8. INTRACTABILITY I poly-time reductions packing and covering problems constraint satisfaction problems sequencing problems partitioning problems graph coloring numerical problems Lecture slides by Kevin

More information

CS103 Handout 09 Fall 2012 October 19, 2012 Problem Set 4

CS103 Handout 09 Fall 2012 October 19, 2012 Problem Set 4 CS103 Handout 09 Fall 2012 October 19, 2012 Problem Set 4 This fourth problem set explores propositional and first-order logic, along with its applications. Once you've completed it, you should have a

More information

NP-Complete Problems. Complexity Class P. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar..

NP-Complete Problems. Complexity Class P. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar.. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar.. Complexity Class P NP-Complete Problems Abstract Problems. An abstract problem Q is a binary relation on sets I of input instances

More information

NP-Completeness and Boolean Satisfiability

NP-Completeness and Boolean Satisfiability NP-Completeness and Boolean Satisfiability Mridul Aanjaneya Stanford University August 14, 2012 Mridul Aanjaneya Automata Theory 1/ 49 Time-Bounded Turing Machines A Turing Machine that, given an input

More information

ECS122A Handout on NP-Completeness March 12, 2018

ECS122A Handout on NP-Completeness March 12, 2018 ECS122A Handout on NP-Completeness March 12, 2018 Contents: I. Introduction II. P and NP III. NP-complete IV. How to prove a problem is NP-complete V. How to solve a NP-complete problem: approximate algorithms

More information

NP-complete problems. CSE 101: Design and Analysis of Algorithms Lecture 20

NP-complete problems. CSE 101: Design and Analysis of Algorithms Lecture 20 NP-complete problems CSE 101: Design and Analysis of Algorithms Lecture 20 CSE 101: Design and analysis of algorithms NP-complete problems Reading: Chapter 8 Homework 7 is due today, 11:59 PM Tomorrow

More information

Mathematical Logic Part One

Mathematical Logic Part One Mathematical Logic Part One Question: How do we formalize the definitions and reasoning we use in our proofs? Where We're Going Propositional Logic (Today) Basic logical connectives. Truth tables. Logical

More information

VIII. NP-completeness

VIII. NP-completeness VIII. NP-completeness 1 / 15 NP-Completeness Overview 1. Introduction 2. P and NP 3. NP-complete (NPC): formal definition 4. How to prove a problem is NPC 5. How to solve a NPC problem: approximate algorithms

More information

Chapter 34: NP-Completeness

Chapter 34: NP-Completeness Graph Algorithms - Spring 2011 Set 17. Lecturer: Huilan Chang Reference: Cormen, Leiserson, Rivest, and Stein, Introduction to Algorithms, 2nd Edition, The MIT Press. Chapter 34: NP-Completeness 2. Polynomial-time

More information

NP and NP Completeness

NP and NP Completeness CS 374: Algorithms & Models of Computation, Spring 2017 NP and NP Completeness Lecture 23 April 20, 2017 Chandra Chekuri (UIUC) CS374 1 Spring 2017 1 / 44 Part I NP Chandra Chekuri (UIUC) CS374 2 Spring

More information

NP Completeness and Approximation Algorithms

NP Completeness and Approximation Algorithms Winter School on Optimization Techniques December 15-20, 2016 Organized by ACMU, ISI and IEEE CEDA NP Completeness and Approximation Algorithms Susmita Sur-Kolay Advanced Computing and Microelectronic

More information

Mathematical Logic Part One

Mathematical Logic Part One Mathematical Logic Part One Question: How do we formalize the definitions and reasoning we use in our proofs? Where We're Going Propositional Logic (Today) Basic logical connectives. Truth tables. Logical

More information

CSCI3390-Second Test with Solutions

CSCI3390-Second Test with Solutions CSCI3390-Second Test with Solutions April 26, 2016 Each of the 15 parts of the problems below is worth 10 points, except for the more involved 4(d), which is worth 20. A perfect score is 100: if your score

More information

Introduction. Pvs.NPExample

Introduction. Pvs.NPExample Introduction Computer Science & Engineering 423/823 Design and Analysis of Algorithms Lecture 09 NP-Completeness (Chapter 34) Stephen Scott (Adapted from Vinodchandran N. Variyam) sscott@cse.unl.edu I

More information