1 / 31

David Evans cs.virginia/evans

Class 14: Intractable Problems. David Evans http://www.cs.virginia.edu/evans. CS150: Computer Science University of Virginia Computer Science. Smileys Problem. Input: n square tiles

marissa
Download Presentation

David Evans cs.virginia/evans

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

  3. Thanks to Peggy Reed for making the Smiley Puzzles!

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

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

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

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

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

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

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

  11. Orders of Growth smileys puzzle simulating universe insertsort quicksort

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

  13. Quiz Break

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

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

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

  17. This makes a huge difference! n! 2n time since “Big Bang” 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

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

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

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

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

  22. 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. PropositionExample Sentence ::= Clause Clause ::= Clause1 Clause2 (or) Clause ::= Clause1Clause2 (and) Clause ::= Clause (not) Clause ::= ( Clause ) Clause ::= Name a  (b  c)  b  c

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

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

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

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

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

More Related