David Evans CS200: Computer Science University of Virginia Computer Science Class 38: Intractable Problems (Smiley Puzzles.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

Spring Process Control Spring Outline 1.Optimization 2.Statistical Process Control 3.In-Process Control.
P, NP, NP-Complete Problems
Complexity. P=NP? Who knows? Who cares? Lets revisit some questions from last time – How many pairwise comparisons do I need to do to check if a sequence.
Part VI NP-Hardness. Lecture 23 Whats NP? Hard Problems.
David Evans cs302: Theory of Computation University of Virginia Computer Science Lecture 17: ProvingUndecidability.
An Advanced Shell Theory Based Tire Model by D. Bozdog, W. W. Olson Department of Mechanical, Industrial and Manufacturing Engineering The 23 rd Annual.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 6: Cons car cdr sdr wdr.
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.
1 P, NP, and NP-Complete Dr. Ying Lu RAIK 283 Data Structures & Algorithms.
Complexity Classes: P and NP
8 April Doors TM Set System Options. 8 April Set System Options Allows you to set certain standard Doors operating parameters and enable certain.
1 The Limits of Computation Intractable and Non-computable functions.
NP-Completeness Lecture for CS 302. Traveling Salesperson Problem You have to visit n cities You want to make the shortest trip How could you do this?
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 
© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of NP-Completeness.
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
NP-complete and NP-hard problems
Analysis of Algorithms CS 477/677
Chapter 11: Limitations of Algorithmic Power
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
NP-Complete Problems CSC 331: Algorithm Analysis NP-Complete Problems.
Scott Perryman Jordan Williams.  NP-completeness is a class of unsolved decision problems in Computer Science.  A decision problem is a YES or NO answer.
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.
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.
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.
1 1. Draw the machine schema for a TM which when started with input 001 halts with abbb on the tape in our standard input format. 2. Suppose you have an.
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.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
NP-Complete problems.
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.
Complexity & Computability. Limitations of computer science  Major reasons useful calculations cannot be done:  execution time of program is too long.
“One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”
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 Computability Tractable, Intractable and Non-computable functions.
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.
1 The Theory of NP-Completeness 2 Review: Finding lower bound by problem transformation Problem X reduces to problem Y (X  Y ) iff X can be solved by.
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.
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,
Richard Anderson Lecture 26 NP-Completeness
Intro to Theory of Computation
Class 14: Intractable Problems CS150: Computer Science
Lecture 22: P = NP? CS200: Computer Science University of Virginia
Chapter 11 Limitations of Algorithm Power
CS 3343: Analysis of Algorithms
The Theory of NP-Completeness
NP-Completeness Lecture for CS 302.
CSC 380: Design and Analysis of Algorithms
Presentation transcript:

David Evans CS200: Computer Science University of Virginia Computer Science Class 38: Intractable Problems (Smiley Puzzles and Curing Cancer)

21 April 2004CS 200 Spring Complexity and Computability We’ve learned how to measure the complexity of any procedure (  ) –Average score on question 6 (8.9/10), 7 (8.6/10) and 8 (8.1/10) We’ve learned how to show some problems are undecidable –Harder (average on question 4 = 7.7) Today: reasoning about the complexity of some problems

21 April 2004CS 200 Spring Complexity Classes Class P: problems that can be solved in polynomial time by a deterministic TM. O (n k ) for some constant k. Easy problems like simulating the universe are all in P. Class NP: problems that can be solved in polynomial time by a nondeterministic TM Hard problems like the pegboard puzzle sorting are in NP (as well as all problems in P).

21 April 2004CS 200 Spring Problem Classes P NP Decidable Undecidable Sorting:  (n log n) Simulating Universe: O(n 3 ) Cracker Barrel: O(2 n ) and  (n) Fill tape with 2 n *s:  (2 n ) Halting Problem:  (  )

21 April 2004CS 200 Spring 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)

21 April 2004CS 200 Spring If P  NP: P NP Decidable Undecidable Sorting:  (n log n) Simulating Universe: O(n 3 ) Cracker Barrel: O(2 n ) and  (n) Fill tape with 2 n *s:  (2 n ) Halting Problem:  (  )

21 April 2004CS 200 Spring If P = NP: P NP Decidable Undecidable Sorting:  (n log n) Simulating Universe: O(n 3 ) Cracker Barrel: O(2 n ) and  (n) Fill tape with 2 n *s:  (2 n ) Halting Problem:  (  )

21 April 2004CS 200 Spring 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!

21 April 2004CS 200 Spring 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: (  ) N o one knows!

21 April 2004CS 200 Spring NP Problems 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)

21 April 2004CS 200 Spring Is the Smiley’s Problem in P? No one knows! We can’t find a O( n k ) solution. We can’t prove one doesn’t exist.

21 April 2004CS 200 Spring This makes a huge difference! n! 2n2n n2n2 n log n today 2032 time since “Big Bang” log-log scale 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!

21 April 2004CS 200 Spring 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

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

21 April 2004CS 200 Spring The Real 3SAT Problem (also can be quickly transformed into the Smileys Puzzle)

21 April 2004CS 200 Spring Propositional Grammar Sentence ::= Clause Sentence Rule: Evaluates to value of Clause Clause ::= Clause 1  Clause 2 Or Rule: Evaluates to true if either clause is true Clause ::= Clause 1  Clause 2 And Rule: Evaluates to true iff both clauses are true

21 April 2004CS 200 Spring 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.

21 April 2004CS 200 Spring Proposition Example Sentence ::= Clause Clause ::= Clause 1  Clause 2 (or) Clause ::= Clause 1  Clause 2 (and) Clause ::=  Clause (not) Clause ::= ( Clause ) Clause ::= Name a  (b  c)   b  c

21 April 2004CS 200 Spring 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)

21 April 2004CS 200 Spring 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 Sentence ::= Clause Clause ::= Clause 1  Clause 2 (or) Clause ::= Clause 1  Clause 2 (and) Clause ::=  Clause (not) Clause ::= ( Clause ) Clause ::= Name

21 April 2004CS 200 Spring 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)

21 April 2004CS 200 Spring SAT / 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.

21 April 2004CS 200 Spring SAT Example 3SAT ( (a  b   c)  (  a   b  d)  (  a  b   d)  (b   c  d ) )  { a: true, b: false, c: false, d: false } Sentence ::= Clause Clause ::= Clause 1  Clause 2 (or) Clause ::= Clause 1  Clause 2 (and) Clause ::=  Clause (not) Clause ::= ( Clause ) Clause ::= Name

21 April 2004CS 200 Spring SAT  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!

21 April 2004CS 200 Spring 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!

21 April 2004CS 200 Spring NP-Complete Problems Easy way to solve by trying all possible guesses If given the “yes” answer, quick (in P) way to check if it is right –Solution to puzzle (see if it looks right) –Assignments of values to names (evaluate logical proposition in linear time) If given the “no” answer, no quick way to check if it is right –No solution (can’t tell there isn’t one) –No way (can’t tell there isn’t one)

21 April 2004CS 200 Spring Traveling Salesperson Problem –Input: a graph of cities and roads with distance connecting them and a minimum total distant –Output: either a path that visits each with a cost less than the minimum, or “no”. If given a path, easy to check if it visits every city with less than minimum distance traveled

21 April 2004CS 200 Spring Graph Coloring Problem –Input: a graph of nodes with edges connecting them and a minimum number of colors –Output: either a coloring of the nodes such that no connected nodes have the same color, or “no”. If given a coloring, easy to check if it no connected nodes have the same color, and the number of colors used.

21 April 2004CS 200 Spring Pegboard Problem - Input: a configuration of n pegs on a cracker barrel style pegboard - Output: if there is a sequence of jumps that leaves a single peg, output that sequence of jumps. Otherwise, output false. If given the sequence of jumps, easy (O( n )) to check it is correct. If not, hard to know if there is a solution. Proof that variant of this problem is NP-Complete is attached to today’s notes.

21 April 2004CS 200 Spring Minesweeper Consistency Problem –Input: a position of n squares in the game Minesweeper –Output: either a assignment of bombs to squares, or “no”. If given a bomb assignment, easy to check if it is consistent.

21 April 2004CS 200 Spring Drug Discovery Problem –Input: a set of proteins, a desired 3D shape –Output: a sequence of proteins that produces the shape (or impossible) Note: US Drug sales = $200B/year If given a sequence, easy (not really) to check if sequence has the right shape. Caffeine

21 April 2004CS 200 Spring Is it ever useful to be confident that a problem is hard?