David Evans Class 15: P vs. NP (Smiley Puzzles and Curing Cancer) CS150: Computer Science University of Virginia Computer.

Slides:



Advertisements
Similar presentations
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.
Advertisements

David Evans cs302: Theory of Computation University of Virginia Computer Science Lecture 17: ProvingUndecidability.
Class 3: Rules of Evaluation David Evans cs1120 Fall 2009.
David Evans CS200: Computer Science University of Virginia Computer Science Class 38: Intractable Problems (Smiley Puzzles.
NP-Hard Nattee Niparnan.
Cs1120 Fall 2009 David Evans Lecture 16: Power Analysis.
Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.
The Theory of NP-Completeness
S.T.A.I.R.. General problem solving strategy that can be applied to a range problems.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 16: Quicker Sorting.
Humans, Computers, and Computational Complexity J. Winters Brock Nathan Kaplan Jason Thompson.
Analysis of Algorithms CS 477/677
CS503: First Lecture, Fall 2008 Michael Barnathan.
Welcome to SCEN101 Physics for Poets George Watson Sharp Lab 232 Office Hours: Monday 7:25-8:15am Friday 5:00-6:00pm.
David Evans cs302: Theory of Computation University of Virginia Computer Science Lecture 2: Modeling Computers.
David Evans CS200: Computer Science University of Virginia Computer Science Class 31: Universal Turing Machines.
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.
Class 5: Constructing Procedures David Evans cs1120 Fall 2009.
Syllabus and Class Policies MATH 130: Summer 2014.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 4: Introducing Recursive Definitions.
David Evans Class 13: Quicksort, Problems and Procedures CS150: Computer Science University of Virginia Computer Science.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 2: Orders of Growth
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.
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.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
Fall 2014 MATH 250: Calculus III. Course Topics Review: Parametric Equations and Polar Coordinates Vectors and Three-Dimensional Analytic Geometry.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 3: Rules of Evaluation.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 3: Levels of Abstraction
Class 21: Introducing Complexity David Evans cs302: Theory of Computation University of Virginia Computer Science.
Class 24: P=NP? David Evans cs302: Theory of Computation University of Virginia Computer Science PS6 (the last one) is.
1 My office hours My office is 319 office hours this week: Friday 12:45-2:15 No office hours next week (week 8, April 6 th ) Contact me:
CS 345 – Software Engineering Nancy Harris ISAT/CS 217
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 4: The Value of Everything.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 5: Recursing on Lists.
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.
REMINDER: If you haven’t yet passed the Gateway Quiz, make sure you take it this week! (You can find more practice quizzes online in the Gateway Info menu.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 8: Crash Course in Computational Complexity.
Lecture 3: Rules of Evaluation CS150: Computer Science
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.
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.
REMINDER: If you haven’t yet passed the Gateway Quiz, make sure you take it this week! (You can find more practice quizzes online in the Gateway Info menu.
David Evans CS200: Computer Science University of Virginia Computer Science Class 26: Halting Problem It is plain at any.
David Evans CS200: Computer Science University of Virginia Computer Science Class 19: Computability Halting Problems Hockey.
3.5 General feeling that knowledge of hydrology has improved … but more is needed.
David Evans Lecture 41: P = NP? I will have extra office hours after class today (1-3pm). To be eligible to present Monday,
Lecture 4: Evaluation Rules Recursion CS200: Computer Science
Class 30: Models of Computation CS200: Computer Science
Lecture 22 Complexity and Reductions
Class 14: Intractable Problems CS150: Computer Science
Lecture 25: Metalinguistics > (meval '((lambda (x) (* x x)) 4)
Lecture 22: P = NP? CS200: Computer Science University of Virginia
Lecture 24: Metalinguistics CS200: Computer Science
Class 24: Computability Halting Problems Hockey Team Logo
Class 34: Models of Computation CS200: Computer Science
Cs1120 Fall 2009 David Evans Lecture 10: Fracturing Fractals cs1120 Fall 2009 David Evans
Lecture 23: Computability CS200: Computer Science
Lecture 22 Complexity and Reductions
Presentation transcript:

David Evans Class 15: P vs. NP (Smiley Puzzles and Curing Cancer) CS150: Computer Science University of Virginia Computer Science

2 CS150 Fall 2005: Lecture 15: P vs NP Menu Complexity Classes P and NP Quiz Answers Problem Reductions

3 CS150 Fall 2005: Lecture 15: P vs NP 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”. “Not possible”

4 CS150 Fall 2005: Lecture 15: P vs NP 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”.

5 CS150 Fall 2005: Lecture 15: P vs NP 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!

6 CS150 Fall 2005: Lecture 15: P vs NP 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)

7 CS150 Fall 2005: Lecture 15: P vs NP Complexity Classes Class P: problems that can be solved in polynomial time ( 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 machine: includes all problems in P and some problems possibly outside P like the Smileys puzzle

8 CS150 Fall 2005: Lecture 15: P vs NP Problem Classes: Possible View P NP Sorting:  (n log n) Simulating Universe: O(n 3 ) Smileys: O(n!) and  (n) Find Best:  (n) (n)(n) How many problems are in the  (n) class? How many problems are in P but not in the  (n) class? How many problems are in NP but not in P? infinite Either 0 or infinite! infinite

9 CS150 Fall 2005: Lecture 15: P vs NP P = NP? Is P different from NP: is there a problem in NP that is not also in P –If there is one, there are infinitely many Is the “hardest” problem in NP also in P –If it is, then every problem in NP is also in P No one knows the answer! The most famous unsolved problem in computer science and math –Listed first on Millennium Prize Problems

10 CS150 Fall 2005: Lecture 15: P vs NP Problem Classes if P  NP: P NP Sorting:  (n log n) Simulating Universe: O(n 3 ) Smileys: O(n!) and  (n) Find Best:  (n) (n)(n) How many problems are in the  (n) class? How many problems are in P but not in the  (n) class? How many problems are in NP but not in P? infinite

11 CS150 Fall 2005: Lecture 15: P vs NP Problem Classes if P = NP: P Sorting:  (n log n) Simulating Universe: O(n 3 ) Smileys:  (n k ) Find Best:  (n) (n)(n) How many problems are in the  (n) class? How many problems are in P but not in the  (n) class? How many problems are in NP but not in P? infinite 0

12 CS150 Fall 2005: Lecture 15: P vs NP Quiz Responses Partners for PS3 –Only 4 groups worked as partners –All partner groups got Gold stars –Only 8 out of 20 non-partner PS got Gold stars Your responses: –Learn more working alone: 7 –Finish faster working alone: 5 –Couldn’t find anyone to work with: 2 –Wanted to work with PS1/PS2 partner: 4 –Started too late: 5

13 CS150 Fall 2005: Lecture 15: P vs NP Quiz Responses How fast: –Way too fast: 1 –Too fast: 11 –Just about right: 11 –Too slow: 1 Exam 1: –Very confident: 1 –Confident: 4 –Concerned: 12 –Worried: 5 –Terrified: 3 AC’s review session: Wednesday at 7 My office hours: Tuesday, 3:30-4:30 Thursday, 11:30am-12:30pm others by request

14 CS150 Fall 2005: Lecture 15: P vs NP What should be Different Maybe I’ve missed it, but beyond a cursory explanation of the meaning of the title of this course on the first day, I don't feel like I have an idea of where we're going with the material we're learning. What will I understand in a month/at the end of this course? It would be good to do some review from the previous class before jumping into lecture, I think I would digest more that way; A little slower; slow down a little I wish lecture was a little slower, more chance to think. Sometimes questions get answered before I've had a chance to think about it. Other than that, its not too bad, I'm definitely challenged by the problem sets, but it's interesting and I like the concepts. More puzzles and logic problems; More interactivity in lectures (stuff like the puzzle); Maybe more interactive things like have us work on a procedure (ex. One of the sorts) in class and then go over an answer (I know it sounds tedious) something that reinforces concepts were's working on less programming! I know this is CS and all, and I find the ideas/problems with CS fascinating. I am horrible at programming; More conceptual description of the concepts as they are introduced. Shorter problem sets so that it is more feasible to do them without a partner; Maybe a slower pace with some review every few classes. The problem sets take a long time for me and I find myself losing time I would spend studying for other subjects so I can finish a problem set in time. Maybe they could be shorter? It would be interesting to work with other languages as well in addition to Scheme We’ll try to do this in Wednesday’s class PS7 and PS8 will use different languages

15 CS150 Fall 2005: Lecture 15: P vs NP Other Response “I decided to skip this problem set, since the lowest grade gets dropped because of conflicts with other courses” This is not the intent of (from the Syllabus): “For almost all students, doing the problem sets will be the best way to learn the course material. … Grades will be tabulated varying the weights assigned to each category in several different ways using the ranges above. Some of those weightings will drop the lowest problem set score. In general, the weighting that is best for you is used.” The main point of the problem sets is to learn the material! (Note: student who answered this was the only one to also select “Way Too Fast” for question 2. If you don’t do the PS, the course will definitely seem way too fast!

16 CS150 Fall 2005: Lecture 15: P vs NP We will go over the other questions on the Quiz Wednesday.

17 CS150 Fall 2005: Lecture 15: P vs NP Who cares about Smiley puzzles? If we had a polynomial time procedure to solve the smiley puzzle, we would also have a fast procedure to solve the 3/stone/apple/tower puzzle: 3

18 CS150 Fall 2005: Lecture 15: P vs NP 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

19 CS150 Fall 2005: Lecture 15: P vs NP Reductions Problem A reduces to Problem B if: –There is a polynomial time function f such that A(x) = B(f (x)) –To reduce “3SAT” to “Smiley”: A = 3SAT B = Smiley f = tile replacements If A reduces B that means solving A is no harder than solving B since we can use a solution to B with f to solve A 

20 CS150 Fall 2005: Lecture 15: P vs NP The Real 3SAT Problem (also can be reduced to the Smileys Puzzle)

21 CS150 Fall 2005: Lecture 15: P vs NP 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

22 CS150 Fall 2005: Lecture 15: P vs NP 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.

23 CS150 Fall 2005: Lecture 15: P vs NP 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

24 CS150 Fall 2005: Lecture 15: P vs NP 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)

25 CS150 Fall 2005: Lecture 15: P vs NP 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

26 CS150 Fall 2005: Lecture 15: P vs NP 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)

27 CS150 Fall 2005: Lecture 15: P vs NP 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.

28 CS150 Fall 2005: Lecture 15: P vs NP Charge Wednesday’s class: recap in context of everything so far Friday: how Lorenz was really broken AC’s exam review is Wednesday, 7pm