Complexity Theory Part Two

Similar documents
Complexity Theory Part Two

Complexity Theory Part Two

Complexity Theory Part Two

NP-Completeness Part One

NP-Completeness Part I

NP-Completeness Part One

NP-Completeness Part One

NP-Completeness Part One

Complexity Theory Part One

NP-Completeness Part II

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

Recap from Last Time

Complexity Theory Part II

Recap from Last Time

NP-Completeness Part II

Complexity Theory Part I

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?

NP-Completeness Part II

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

Complexity Theory Part I

CMSC 441: Algorithms. NP Completeness

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

Congratulations you're done with CS103 problem sets! Please evaluate this course on Axess!

Announcements. Using a 72-hour extension, due Monday at 11:30AM.

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

Topics in Complexity Theory

CSEP 521 Applied Algorithms. Richard Anderson Winter 2013 Lecture 1

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: NP-Completeness I Date: 11/13/18

Turing Machines Part Two

Lecture 22: PSPACE

Topics in Complexity

Congratulations you're done with CS103 problem sets! Please evaluate this course on Axess!

Intro to Theory of Computation

Approximation Algorithms

Course Staff. Textbook

Announcements. Final exam review session tomorrow in Gates 104 from 2:15PM 4:15PM Final Friday Four Square of the quarter!

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

conp, Oracles, Space Complexity

Essential facts about NP-completeness:

CS154, Lecture 17: conp, Oracles again, Space Complexity

CS154, Lecture 13: P vs NP

Decidability and Undecidability

Lecture 23: More PSPACE-Complete, Randomized Complexity

Undecidability and Rice s Theorem. Lecture 26, December 3 CS 374, Fall 2015

SAT, NP, NP-Completeness

(Note that these points are to give a relative sense of the weights on the final exam and have no bearing on extra credit points)

Congratulations you're done with CS103 problem sets! Please evaluate this course on Axess!

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

Finite Automata Part Two

Complexity Theory Part One

COP 4531 Complexity & Analysis of Data Structures & Algorithms

Finite Automata Part One

CS5371 Theory of Computation. Lecture 19: Complexity IV (More on NP, NP-Complete)

15.1 Proof of the Cook-Levin Theorem: SAT is NP-complete

POLYNOMIAL SPACE QSAT. Games. Polynomial space cont d

CS Lecture 29 P, NP, and NP-Completeness. k ) for all k. Fall The class P. The class NP

1 PSPACE-Completeness

Mathematical Logic Part One

Nonregular Languages

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

Turing Machines Part One

CSE 105 Theory of Computation

CS154, Lecture 13: P vs NP

A Note on Turing Machine Design

Finite Automata Part One

6-1 Computational Complexity

Lecture 20: conp and Friends, Oracles in Complexity Theory

Exam Computability and Complexity

Algorithm Design and Analysis

1 Computational problems

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).

Outline for Today. Binary Relations. Equivalence Relations. Partial Orders. Quick Midterm Review

Finite Automata Part One

NP-Completeness and Boolean Satisfiability

CSE 105 THEORY OF COMPUTATION

Definition: conp = { L L NP } What does a conp computation look like?

Lecture Notes 4. Issued 8 March 2018

Announcements. Problem Set Four due Thursday at 7:00PM (right before the midterm).

Turing Machines Part II

Computability Theory

Artificial Intelligence. 3 Problem Complexity. Prof. Dr. Jana Koehler Fall 2016 HSLU - JK

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

CSCI3390-Lecture 14: The class NP

DRAFT. Diagonalization. Chapter 4

CS 301. Lecture 17 Church Turing thesis. Stephen Checkoway. March 19, 2018

Design and Analysis of Algorithms

Turing Machines Part III

Regular Languages and Finite Automata

Space Complexity. Huan Long. Shanghai Jiao Tong University

Outline. Complexity Theory. Example. Sketch of a log-space TM for palindromes. Log-space computations. Example VU , SS 2018

NP-Completeness Review

Show that the following problems are NP-complete

Overview, cont. Overview, cont. Logistics. Optional Reference #1. Optional Reference #2. Workload and Grading

NP and NP Completeness

Practice Second Midterm Exam I

Space Complexity. then the space required by M on input x is. w i u i. F ) on. September 27, i=1

CS 583: Algorithms. NP Completeness Ch 34. Intractability

Turing Machines and Time Complexity

Turing Machines Part II

Lecture 14 - P v.s. NP 1

Transcription:

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 if it can be decided in time O(n k ) for some k N. Like Like the the Church-Turing thesis, this this is is not not a theorem! It's It's an an assumption about about the the nature of of eficient computation, and and it it is is somewhat controversial.

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 is a polynomial-time decider for L } Assuming the Cobham-Edmonds thesis, a language is in P if it can be decided eficiently.

Polynomial-Time Verifers A polynomial-time verifer for L is a TM V such that V halts on all inputs. w L if c Σ*. V accepts w, c. V's runtime is a polynomial in w (that is, V's runtime is O( w k ) for some integer k)

The Complexity Class NP The complexity class NP (nondeterministic polynomial time) contains all problems that can be verifed in polynomial time. Formally: NP = { L There is a polynomial-time verifer for L } The name NP comes from another way of characterizing NP. If you introduce nondeterministic Turing machines and appropriately defne polynomial time, then NP is the set of problems that an NTM can solve in polynomial time.

Theorem (Baker-Gill-Solovay): Any proof that purely relies on universality and self-reference cannot resolve P NP. Proof: Take CS154!

So how are we going to reason about P and NP?

New Stuf!

A Challenge

REG P NP Problems in NP vary widely in their dificulty, even if P = NP. How can we rank the relative dificulties of problems?

Reducibility

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 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 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.

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.

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 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 Matching Jack Edmonds' paper Paths, Trees, and Flowers gives a polynomial-time algorithm for fnding maximum matchings. (This is the same Edmonds as in Cobham- Edmonds Thesis. ) Using this fact, what other problems can we solve?

Domino Tiling

Domino Tiling

Domino Tiling

Domino Tiling

Domino Tiling

Domino Tiling

Solving Domino Tiling

Solving Domino Tiling

Solving Domino Tiling

Solving Domino Tiling

Solving Domino Tiling

Solving Domino Tiling

Solving Domino Tiling

Solving Domino Tiling

In Pseudocode boolean canplacedominos(grid G, int k) { } return hasmatching(gridtograph(g), k);

Based Based on on this this connection connection between between maximum maximum matching matching and and domino domino tiling, tiling, which which of of the the following following statements statements would would be be more more proper proper to to conclude? conclude? A. A. Finding Finding a a maximum maximum matching matching isn t isn t any any more more dificult dificult than than tiling tiling a a grid grid with with dominoes. dominoes. B. B. Tiling Tiling a a grid grid with with dominoes dominoes isn t isn t any any more more dificult dificult than than fnding fnding a a maximum maximum matching. matching. Answer Answer at at PollEv.com/cs103 PollEv.com/cs103 or or text text CS103 CS103 to to 22333 22333 once once to to join, join, then then A A or or B. B.

Intuition: Tiling a grid with dominoes can't be harder than solving maximum matching, because if we can solve maximum matching eficiently, we can solve domino tiling eficiently.

Another Example

Reachability Consider the following problem: Given an directed graph G and nodes s and t in G, is there a path from s to t? It's known that this problem can be solved in polynomial time (use DFS or BFS). Given that we can solve the reachability problem in polynomial time, what other problems can we solve in polynomial time?

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?

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-Video S-Video to to DVI DVI FireWire FireWire to to SDI SDI VGA VGA to to RGB RGB DVI DVI to to DisplayPort DisplayPort USB USB to to S-Video S-Video SDI SDI to to HDMI HDMI

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-Video S-Video to to DVI DVI FireWire FireWire to to SDI SDI VGA VGA to to RGB RGB DVI DVI to to DisplayPort DisplayPort USB USB to to S-Video S-Video SDI SDI to to HDMI HDMI VGA RGB USB DisplayPort DB13W3 CATV HDMI X FireWire DVI S-Video SDI

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

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

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

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-Video S-Video 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-Video S-Video SDI SDI to to HDMI HDMI VGA RGB USB DisplayPort DB13W3 CATV HDMI X FireWire DVI S-Video SDI

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

Based Based on on this this connection connection between between plugging plugging a a laptop laptop into into a a projector projector and and determining determining reachability, reachability, which which of of the the following following statements statements would would be be more more proper proper to to conclude? conclude? A. A. Plugging Plugging a a laptop laptop into into a a projector projector isn t isn t any any more more dificult dificult that that computing computing reachability reachability in in a a directed directed graph. graph. B. B. Computing Computing reachability reachability in in a a directed directed graph graph isn t isn t any any more more dificult dificult than than plugging plugging a a laptop laptop into into a a projector. projector. Answer Answer at at PollEv.com/cs103 PollEv.com/cs103 or or text text CS103 CS103 to to 22333 22333 once once to to join, join, then then A A or or B. B.

Intuition: Finding a way to plug a computer into a projector can't be harder than determining reachability in a graph, since if we can determine reachability in a graph, we can fnd a way to plug a computer into a projector.

bool solveproblema(string input) { return solveproblemb(transform(input)); } Intuition: Problem A can't be harder than problem B, because solving problem B lets us solve problem A.

bool solveproblema(string input) { return solveproblemb(transform(input)); } If A and B are problems where it's possible to solve problem A using the strategy shown above *, we write A p B. We say that A is polynomial-time reducible to B. * Assuming that transform * runs in polynomial time.

Polynomial-Time Reductions If A p B and B P, then A P. If L 1 P L 2 and L 2 NP, then L 1 NP. P

Polynomial-Time Reductions If A p B and B P, then A P. If L 1 P L 2 and L 2 NP, then L 1 NP. P

Polynomial-Time Reductions If A p B and B P, then A P. If L 1 P L 2 and L 2 NP, then L 1 NP. P

Polynomial-Time Reductions If A p B and B P, then A P. If A p B and B NP, then A NP. P

Polynomial-Time Reductions If A p B and B P, then A P. If A p B and B NP, then A NP. P NP

Polynomial-Time Reductions If A p B and B P, then A P. If A p B and B NP, then A NP. P NP

Polynomial-Time Reductions If A p B and B P, then A P. If A p B and B NP, then A NP. P NP

This ₚ relation lets us rank the relative dificulties of problems in P and NP. What else can we do with it?

Time-Out for Announcements!

Please evaluate this course on Axess. Your feedback makes a diference.

Problem Set Nine Problem Set Nine is due this Friday at 2:30PM. No late submissions can be accepted. This is university policy sorry! As always, if you have questions, stop by ofice hours or ask on Piazza!

Final Exam Logistics Our fnal exam is Monday, March 19 th from 3:30PM 6:30PM, location Hewlett 200 & 201 (no special last name assignments). Sorry about how soon that is the registrar picked this time, not us. If we had a choice, it would be on the last day of fnals week. The exam is cumulative. You re responsible for topics from PS1 PS9 and all of the lectures. As with the midterms, the exam is closed-book, closedcomputer, and limited-note. You can bring one doublesided sheet of 8.5 11 notes with you to the exam, decorated any way you d like. Students with OAE accommodations: if we don t yet have your OAE letter, please send it to us ASAP.

Preparing for the Final On the course website you ll fnd six practice fnal exams, which are all real exams with minor modifcations, with solutions, and a giant set of 46 practice problems (EPP3), with solutions. Our recommendation: Look back over the exams and problem sets and redo any problems that you didn t really get the frst time around. Keep the TAs in the loop: stop by ofice hours to have them review your answers and ofer feedback.

Practice Final Exam We will be holding a practice fnal exam in room 380-380X tonight from 7PM 10PM. We ll print out copies of a few of the diferent practice exams and you can pick whichever one you d like!

Back to CS103!

NP-Hardness and NP-Completeness

Question: What makes a problem hard to solve?

Intuition: If A ₚ B, then problem B is at least as hard * as problem A. * for some defnition of at least as hard as.

Intuition: To show that some problem is hard, show that lots of other problems reduce to it.

NP-Hardness A language L is called NP-hard if for every A NP, we have A 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 P

NP-Hardness A language L is called NP-hard if for every A NP, we have A 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

NP-Hardness A language L is called NP-hard if for every A NP, we have A 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

NP-Hardness A language L is called NP-hard if for every A NP, we have A 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 decide all all problems in in NP. NP. A language in L is hard called as NP-complete every problem if L is in NP-hard NP, since and L NP. The class NPC is the set of NP-complete problems. NP NP-Hard P

NP-Hardness A language L is called NP-hard if for every A NP, we have A 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

NP-Hardness A language L is called NP-hard if for every A NP, we have A P L. A language in L is called NP-complete if 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

NP-Hardness A language L is called NP-hard if for every A NP, we have A 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

NP-Hardness A language L is called NP-hard if for every A NP, we have A 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 NPC P

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 consider 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.

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 consider 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

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 consider 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

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 consider 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

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 consider 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

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 consider any arbitrary NP problem A. Since L is NP-complete, we know that A p L. Since L P and A p L, we see that A P. Since our choice of A was arbitrary, this means that NP P, so P = NP. P = NP

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. Therefore, we know that L NP and L P, so P NP. NP P NPC

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

Satisfability A propositional logic formula φ is called satisfable if there is some assignment to its variables that makes it evaluate to true. p q is satisfable. p p is unsatisfable. p (q q) is satisfable. An assignment of true and false to the variables of φ that makes it evaluate to true is called a satisfying assignment.

SAT The boolean satisfability problem (SAT) is the following: Formally: Given a propositional logic formula φ, is φ satisfable? SAT = { φ φ is a satisfable PL formula }

SAT = { φ φ is a satisfable PL formula } The The language language SAT SAT happens happens to to be be in in NP. NP. Think Think about about how how a a polynomial-time polynomial-time verifer verifer for for SAT SAT might might work. work. Which Which of of the the following following would would work work as as certifcates certifcates for for such such a a verifer, verifer, given given that that the the input input is is a a propositional propositional formula formula φ? φ? A. A. The The truth truth table table of of φ. φ. B. B. One One possible possible variable variable assignment assignment to to φ. φ. C. C. A list list of of all all possible possible variable variable assignments assignments for for φ. φ. D. D. None None of of the the above, above, or or two two or or more more of of the the above. above. Answer at PollEv.com/cs103 or Answer at PollEv.com/cs103 or text text CS103 CS103 to to 22333 22333 once once to to join, join, then then A, A, B, B, C, C, or or D. D.

Theorem (Cook-Levin): SAT is NP-complete. Proof Idea: To see that SAT NP, show how to make a polynomial-time verifer for it. Key idea: have the certifcate be a satisfying assignment. To show that SAT is NP-hard, given a polymomial-time verifer V for an arbitrary NP language L, for any string w you can construct a polynomially-sized formula φ(w) that says there is a certifcate c where V accepts w, c. This formula is satisfable if and only if w L, so deciding whether the formula is satisfable decides whether w is in L. Proof: Take CS154!

Theorem (Cook-Levin): SAT is NP-complete. Proof Idea: To see that SAT NP, show how to make a polynomial-time verifer for it. Key idea: have the certifcate be a satisfying assignment. To show that SAT is NP-hard, given a polymomial-time verifer V for an arbitrary NP language L, for any string w you can construct a polynomially-sized formula φ(w) that says there is a certifcate c where V accepts w, c. This formula is satisfable if and only if w L, so deciding whether the formula is satisfable decides whether w is in L. Proof: Take CS154!

Why All This Matters Resolving P NP is equivalent to just fguring out how hard SAT is. If SAT P, then P = NP. If SAT P, then P NP. We've turned a huge, abstract, theoretical problem about solving problems versus checking solutions into the concrete task of seeing how hard one problem is. You can get a sense for how little we know about algorithms and computation given that we can't yet answer this question!

Why All This Matters You will almost certainly encounter NP-hard problems in practice they're everywhere! If a problem is NP-hard, then there is no known algorithm for that problem that is eficient on all inputs, always gives back the right answer, and runs deterministically. Useful intuition: If you need to solve an NP-hard problem, you will either need to settle for an approximate answer, an answer that's likely but not necessarily right, or have to work on really small inputs.

Sample NP-Hard Problems Computational biology: Given a set of genomes, what is the most probable evolutionary tree that would give rise to those genomes? (Maximum parsimony problem) Game theory: Given an arbitrary perfect-information, fnite, twoplayer game, who wins? (Generalized geography problem) Operations research: Given a set of jobs and workers who can perform those tasks in parallel, can you complete all the jobs within some time bound? (Job scheduling problem) Machine learning: Given a set of data, fnd the simplest way of modeling the statistical patterns in that data (Bayesian network inference problem) Medicine: Given a group of people who need kidneys and a group of kidney donors, fnd the maximum number of people who can end up with kidneys (Cycle cover problem) Systems: Given a set of processes and a number of processors, fnd the optimal way to assign those tasks so that they complete as soon as possible (Processor scheduling problem)

Coda: What if P NP is resolved?

Intermediate Problems With few exceptions, every problem we've discovered in NP has either defnitely been proven to be in P, or defnitely been proven to be NP-complete. A problem that's NP, not in P, but not NP-complete is called NP-intermediate. Theorem (Ladner): There are NP-intermediate problems if and only if P NP. NP P NPC

What if P NP?

A Good Read: A Personal View of Average-Case Complexity by Russell Impagliazzo

What if P = NP?

And a Dismal Third Option

Next Time The Big Picture Where to Go from Here A Final Your Questions Parting Words!