Class 14: Intractable Problems CS150: Computer Science

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

NP-Complete Problems CIT 596, Spring Problems that Cross the Line What if a problem has: o An exponential upper bound o A polynomial lower bound.
David Evans CS200: Computer Science University of Virginia Computer Science Class 38: Intractable Problems (Smiley Puzzles.
Time Complexity P vs NP.
1 The Limits of Computation Intractable and Non-computable functions.
The Theory of NP-Completeness
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
Computability and Complexity 13-1 Computability and Complexity Andrei Bulatov The Class NP.
CSE332: Data Abstractions Lecture 27: A Few Words on NP Dan Grossman Spring 2010.
The Theory of NP-Completeness
Analysis of Algorithms CS 477/677
1 CSC 421: Algorithm Design & Analysis Spring 2013 Complexity & Computability  lower bounds on problems brute force, decision trees, adversary arguments,
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
David Evans Class 13: Quicksort, Problems and Procedures CS150: Computer Science University of Virginia Computer Science.
Complexity Classes (Ch. 34) The class P: class of problems that can be solved in time that is polynomial in the size of the input, n. if input size is.
Chapter 7 Inefficiency and Intractability CS 345 Spring Quarter, 2014.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
David Evans Curing Cancer with Your Cell Phone: Why all Sciences are Becoming Computing Sciences.
Problems you shouldn’t tackle. Problem Complexity.
Cs3102: Theory of Computation Class 24: NP-Completeness Spring 2010 University of Virginia David Evans.
David Evans CS588: Security and Privacy University of Virginia Computer Science Lecture 15: Complexity Notes This is selected.
What Every Biologist, Chemist, and Poet Should Know about Computer Science David Evans UVaCompBio 25 April
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
Cliff Shaffer Computer Science Computational Complexity.
David Evans Class 19: Golden Ages and Astrophysics CS200: Computer Science University of Virginia Computer Science.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
1 Chapter 34: NP-Completeness. 2 About this Tutorial What is NP ? How to check if a problem is in NP ? Cook-Levin Theorem Showing one of the most difficult.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
NP-Complete problems.
Beauty and Joy of Computing Limits of Computing Ivona Bezáková CS10: UC Berkeley, April 14, 2014 (Slides inspired by Dan Garcia’s slides.)
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
David Evans Class 16: NP-Completeness / The Story so Far CS150: Computer Science University of Virginia Computer Science.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 15: Intractable Problems (Smiley.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
David Evans Class 15: P vs. NP (Smiley Puzzles and Curing Cancer) CS150: Computer Science University of Virginia Computer.
NPC.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 8: Crash Course in Computational Complexity.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 14: P = NP?
Pancakes, Puzzles, and Polynomials: Cracking the Cracker Barrel Game Christopher Frost Michael Peck.
1 1. Which of these sequences correspond to Hamilton cycles in the graph? (a) (b) (c) (d) (e)
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 23: Intractable Problems (Smiley Puzzles.
COMPLEXITY. Satisfiability(SAT) problem Conjunctive normal form(CNF): Let S be a Boolean expression in CNF. That is, S is the product(and) of several.
CS 154 Formal Languages and Computability May 10 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
The NP class. NP-completeness
NP-Complete Problems.
Chapter 10 NP-Complete Problems.
David Evans Lecture 41: P = NP? I will have extra office hours after class today (1-3pm). To be eligible to present Monday,
Hard Problems Introduction to NP
Lecture 22 Complexity and Reductions
NP-Completeness Yin Tat Lee
Analysis and design of algorithm
ICS 353: Design and Analysis of Algorithms
Lecture 13: Cost of Sorts CS150: Computer Science
Lecture 25: Metalinguistics > (meval '((lambda (x) (* x x)) 4)
Lecture 22: P = NP? CS200: Computer Science University of Virginia
1. for (i=0; i < n; i+=2) if (A[i] > A[i+1]) swap(A[i], A[i+1])
Lecture 24: Metalinguistics CS200: Computer Science
Chapter 11 Limitations of Algorithm Power
NP-Complete Problems.
Algorithms and Data Structures Lecture XV
NP-completeness The Chinese University of Hong Kong Fall 2008
CS 3343: Analysis of Algorithms
Class 24: Computability Halting Problems Hockey Team Logo
CSC 380: Design and Analysis of Algorithms
RAIK 283 Data Structures & Algorithms
Lecture 23: Computability CS200: Computer Science
Lecture 22 Complexity and Reductions
Presentation transcript:

David Evans http://www.cs.virginia.edu/evans Class 14: Intractable Problems CS150: Computer Science University of Virginia Computer Science David Evans http://www.cs.virginia.edu/evans

Smileys Problem Input: n square tiles Output: Arrangement of the tiles in a square, where the colors and shapes match up, or “no, its impossible”.

Thanks to Peggy Reed for making the Smiley Puzzles!

Problems and Procedures To know a O (f) bound for a problem, we need to find a (f) procedure that solves it The sorting problem is O (n log n) since we know a procedure that solves it in (n log n) To know a Ω(f ) bound for a problem, we need to prove that there is no procedure faster than (f) that solves it We proved sorting is Ω(n log n) by reasoning about the number of decisions needed

How much work is the Smiley’s Problem? Upper bound: (O) O (n!) Try all possible permutations Lower bound: ()  (n) Must at least look at every tile Tight bound: () No one knows!

Complexity Class P “Tractable” Class P: problems that can be solved in polynomial time O (nk) for some constant k. Easy problems like sorting, making a photomosaic using duplicate tiles, simulating the universe are all in P.

Complexity Class NP Class NP: problems that can be solved in nondeterministic polynomial time If we could try all possible solutions at once, we could identify the solution in polynomial time. Alternately: If we had a magic guess-correctly procedure that makes every decision correctly, we could devise a procedure that solves the problem in polynomial time. Note: this definition is not precise enough to be satisfying yet! We will need to understand better what a “step” means when we measure work to define this properly.

NP Problems The smileys problem is in NP Can be solved by just trying all possible answers until we find one that is right Easy to quickly check if an answer is right Checking an answer is in P The smileys problem is in NP We can easily try n! different answers We can quickly check if a guess is correct (check all n tiles)

Is the Smiley’s Problem in P? No one knows! We can’t find a O (nk) solution. We can’t prove one doesn’t exist.

Orders of Growth 2n < n! simulating universe smileys puzzle insertsort quicksort

Orders of Growth smileys puzzle simulating universe insertsort quicksort

Orders of Growth Smileys puzzle “intractable” “tractable” simulating universe I do nothing that a man of unlimited funds, superb physical endurance, and maximum scientific knowledge could not do. – Batman (may be able to solve intractable problems, but computer scientists can only solve tractable ones for large n)

Quiz Break

Intractable Problems P n! 2n n2 n log n log-log scale time since “Big Bang” 2n P 2022 today n2 n log n

Moore’s Law Doesn’t Help If the fastest procedure to solve a problem is (2n) or worse, Moore’s Law doesn’t help much. Every doubling in computing power increases the problem size by 1.

P = NP? Is there a polynomial-time solution to the “hardest” problems in NP? No one knows the answer! The most famous unsolved problem in computer science and math Listed first on Millennium Prize Problems win $1M if you can solve it (also an automatic A+ in this course)

This makes a huge difference! time since “Big Bang” 2n Solving a large smileys problem either takes a few seconds, or more time than the universe has been in existence. But, no one knows which for sure! 2032 today n2 n log n log-log scale

Who cares about Smiley puzzles? If we had a fast (polynomial time) procedure to solve the smiley puzzle, we would also have a fast procedure to solve the 3/stone/apple/tower puzzle: 3

3SAT  Smiley     Step 1: Transform into smileys Step 2: Solve (using our fast smiley puzzle solving procedure) Step 3: Invert transform (back into 3SAT problem    

The Real 3SAT Problem (also can be quickly transformed into the Smileys Puzzle)

Propositional Grammar Sentence ::= Clause Sentence Rule: Evaluates to value of Clause Clause ::= Clause1  Clause2 Or Rule: Evaluates to true if either clause is true Clause ::= Clause1  Clause2 And Rule: Evaluates to true iff both clauses are true

Propositional Grammar Clause ::= Clause Not Rule: Evaluates to the opposite value of clause (true  false) Clause ::= ( Clause ) Group Rule: Evaluates to value of clause. Clause ::= Name Name Rule: Evaluates to value associated with Name.

a  (b  c)  b  c Proposition Example Sentence ::= Clause Clause ::= Clause1  Clause2 (or) Clause ::= Clause1  Clause2 (and) Clause ::= Clause (not) Clause ::= ( Clause ) Clause ::= Name Proposition Example a  (b  c)  b  c

The Satisfiability Problem (SAT) Input: a sentence in propositional grammar Output: Either a mapping from names to values that satisfies the input sentence or no way (meaning there is no possible assignment that satisfies the input sentence)

SAT Example SAT (a  (b  c)  b  c) SAT (a  a) Sentence ::= Clause Clause ::= Clause1  Clause2 (or) Clause ::= Clause1  Clause2 (and) Clause ::= Clause (not) Clause ::= ( Clause ) Clause ::= Name SAT Example SAT (a  (b  c)  b  c)  { a: true, b: false, c: true }  { a: true, b: true, c: false } SAT (a  a)  no way

The 3SAT Problem Input: a sentence in propositional grammar, where each clause is a disjunction of 3 names which may be negated. Output: Either a mapping from names to values that satisfies the input sentence or no way (meaning there is no possible assignment that satisfies the input sentence)

3SAT / SAT Is 3SAT easier or harder than SAT? It is definitely not harder than SAT, since all 3SAT problems are also SAT problems. Some SAT problems are not 3SAT problems.

3SAT Example 3SAT ( (a  b   c)  (a   b  d)  (a  b   d) Sentence ::= Clause Clause ::= Clause1  Clause2 (or) Clause ::= Clause1  Clause2 (and) Clause ::= Clause (not) Clause ::= ( Clause ) Clause ::= Name 3SAT Example 3SAT ( (a  b   c)  (a   b  d)  (a  b   d)  (b   c  d ) )  { a: true, b: false, c: false, d: false}

3SAT  Smiley Like 3/stone/apple/tower puzzle, we can convert every 3SAT problem into a Smiley Puzzle problem! Transformation is more complicated, but still polynomial time. So, if we have a fast (P) solution to Smiley Puzzle, we have a fast solution to 3SAT also!

NP Complete Cook and Levin proved that 3SAT was NP-Complete (1971) A problem is NP-complete if it is as hard as the hardest problem in NP If 3SAT can be transformed into a different problem in polynomial time, than that problem must also be NP-complete. Either all NP-complete problems are tractable (in P) or none of them are!

Charge PS4 is due Monday More on P vs. NP next class