Tetris is Hard: An Introduction to P vs NP



Similar documents
A Working Knowledge of Computational Complexity for an Optimizer

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

CSC 373: Algorithm Design and Analysis Lecture 16

NP-complete? NP-hard? Some Foundations of Complexity. Prof. Sven Hartmann Clausthal University of Technology Department of Informatics

OHJ-2306 Introduction to Theoretical Computer Science, Fall

Tutorial 8. NP-Complete Problems

Page 1. CSCE 310J Data Structures & Algorithms. CSCE 310J Data Structures & Algorithms. P, NP, and NP-Complete. Polynomial-Time Algorithms

Introduction to Algorithms. Part 3: P, NP Hard Problems

SIMS 255 Foundations of Software Design. Complexity and NP-completeness

Lecture 7: NP-Complete Problems

Computer Algorithms. NP-Complete Problems. CISC 4080 Yanjun Li

Introduction to Logic in Computer Science: Autumn 2006

1. Nondeterministically guess a solution (called a certificate) 2. Check whether the solution solves the problem (called verification)

P versus NP, and More

Ian Stewart on Minesweeper

CAD Algorithms. P and NP

Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits

Complexity Theory. IE 661: Scheduling Theory Fall 2003 Satyaki Ghosh Dastidar

NP-Completeness and Cook s Theorem

NP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness

Complexity Classes P and NP

Why Study NP- hardness. NP Hardness/Completeness Overview. P and NP. Scaling 9/3/13. Ron Parr CPS 570. NP hardness is not an AI topic

Some Minesweeper Configurations

Complexity Theory. Jörg Kreiker. Summer term Chair for Theoretical Computer Science Prof. Esparza TU München

Why? A central concept in Computer Science. Algorithms are ubiquitous.

ON THE COMPLEXITY OF THE GAME OF SET.

Theoretical Computer Science (Bridging Course) Complexity

Lecture 2: Complexity Theory Review and Interactive Proofs

Lecture 19: Introduction to NP-Completeness Steven Skiena. Department of Computer Science State University of New York Stony Brook, NY

The Classes P and NP

Quantum and Non-deterministic computers facing NP-completeness

Computational complexity theory

Diagonalization. Ahto Buldas. Lecture 3 of Complexity Theory October 8, Slides based on S.Aurora, B.Barak. Complexity Theory: A Modern Approach.

Offline 1-Minesweeper is NP-complete

Lecture 30: NP-Hard Problems [Fa 14]

The Theory of Tetris

! X is a set of strings. ! Instance: string s. ! Algorithm A solves problem X: A(s) = yes iff s! X.

Reductions & NP-completeness as part of Foundations of Computer Science undergraduate course

Chapter 1. NP Completeness I Introduction. By Sariel Har-Peled, December 30, Version: 1.05

WHAT ARE MATHEMATICAL PROOFS AND WHY THEY ARE IMPORTANT?

Introduction to computer science

Probability and Statistics Prof. Dr. Somesh Kumar Department of Mathematics Indian Institute of Technology, Kharagpur

NP-completeness and the real world. NP completeness. NP-completeness and the real world (2) NP-completeness and the real world

Quantum Monte Carlo and the negative sign problem

Revised Version of Chapter 23. We learned long ago how to solve linear congruences. ax c (mod m)

How To Solve A Minimum Set Covering Problem (Mcp)

Near Optimal Solutions

Boulder Dash is NP hard

The P versus NP Solution

On the Relationship between Classes P and NP

Factoring & Primality

Guessing Game: NP-Complete?

NSM100 Introduction to Algebra Chapter 5 Notes Factoring

One last point: we started off this book by introducing another famously hard search problem:

CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 313]

Million Dollar Mathematics!

Cloud Computing is NP-Complete

CoNP and Function Problems

Chapter. NP-Completeness. Contents

8 Primes and Modular Arithmetic

Welcome to... Problem Analysis and Complexity Theory , 3 VU

Sowing Games JEFF ERICKSON

A Second Course in Mathematics Concepts for Elementary Teachers: Theory, Problems, and Solutions

b) since the remainder is 0 I need to factor the numerator. Synthetic division tells me this is true

Zeros of Polynomial Functions

Alex, I will take congruent numbers for one million dollars please

The Taxman Game. Robert K. Moniot September 5, 2003

The Challenger-Solver game: Variations on the theme of P =?NP

PUTNAM TRAINING POLYNOMIALS. Exercises 1. Find a polynomial with integral coefficients whose zeros include

WRITING PROOFS. Christopher Heil Georgia Institute of Technology

Factoring Trinomials: The ac Method

Lecture 13 - Basic Number Theory.

3.2 The Factor Theorem and The Remainder Theorem

Return on Investment (ROI)

2.5 Zeros of a Polynomial Functions

If A is divided by B the result is 2/3. If B is divided by C the result is 4/7. What is the result if A is divided by C?

CHOOSING THE BEST HEURISTIC FOR A NP-PROBLEM

March 29, S4.4 Theorems about Zeros of Polynomial Functions

The Hardness of the Lemmings Game, or Oh no, more NP-Completeness Proofs

Notes on NP Completeness

MATHEMATICS: CONCEPTS, AND FOUNDATIONS Vol. III - Logic and Computer Science - Phokion G. Kolaitis

2. (a) Explain the strassen s matrix multiplication. (b) Write deletion algorithm, of Binary search tree. [8+8]

MA 1125 Lecture 14 - Expected Values. Friday, February 28, Objectives: Introduce expected values.

Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay

Theorem (informal statement): There are no extendible methods in David Chalmers s sense unless P = NP.

The Turing Test! and What Computer Science Offers to Cognitive Science "

Problem Set 7 Solutions

Chapter 4 Lecture Notes

ALGEBRA 2 CRA 2 REVIEW - Chapters 1-6 Answer Section

Classification - Examples

Lecture 3: One-Way Encryption, RSA Example

SOLVING NARROW-INTERVAL LINEAR EQUATION SYSTEMS IS NP-HARD PATRICK THOR KAHL. Department of Computer Science

Lecture 2: Universality

SECTION 10-2 Mathematical Induction

Ready, Set, Go! Math Games for Serious Minds

Scheduling Home Health Care with Separating Benders Cuts in Decision Diagrams

Transcription:

Tetris is Hard: An Introduction to P vs NP Based on Tetris is Hard, Even to Approximate in COCOON 2003 by Erik D. Demaine (MIT) Susan Hohenberger (JHU) David Liben-Nowell (Carleton)

What s Your Problem? A language is a set of strings: PRIMES = {2, 3, 5, 7, 11, 13, 17, 19, 23,...} We are interested in the following kind of decision problem: Given x, is x PRIMES? How much harder does this question get as x gets larger? 1

The Tetris Problem So what do we mean by Tetris? Offline Tetris: get to see entire piece sequence in advance. Advanced level: the initial board is partially filled. TETRIS = { g, s : can play piece sequence s to clear entire gameboard g} g, s TETRIS: given a gameboard and a piece sequence, can we clear the entire board using the given sequence? 2

Instances of Decision Problems Is 357667 PRIMES? Is, TETRIS? How much harder does this get as the gameboard gets bigger? Find an algorithm A that decides if g, s TETRIS. Measure resources consumed by A. 3

Measuring Resource Usage How do we measure the resources consumed by A? Be pessimistic. Always consider the worst instance of a given size. Resources: time, space. Run A on all instances of size n on some computer. Graph n versus the amount of each resource consumed by A on the most consuming instance of size n. 200 12 x 105 180 160 10 140 8 120 100 6 80 60 4 40 2 20 0 0 1 2 3 4 5 6 7 8 9 10 Polynomial 0 0 2 4 6 8 10 12 14 16 18 20 Exponential 4

A Computer Theorist s Worldview Easy Computable Uncomputable Hard Is this number prime? Will 463 beat 363 s median on Quiz 3? Will Windows crash when I load this web page? Can I color this map with three colors? Are all the numbers in this list positive? 5

Complexity Classes A complexity class is a set of languages. A language L (PRIMES, TETRIS,...) is a member of the following complexity classes if there is an algorithm A... P PSPACE EXPTIME... deciding all questions x L in polynomial time. e.g., for every x, time taken by A(x) is 10 x 3. Games: JENGA... deciding all questions x L in polynomial space. Games: GO (in some countries), OTHELLO... deciding all questions x L in exponential time. Games: CHESS, CHECKERS 6

Complexity Hierarchy EXPTIME PSPACE Efficient Space P Efficient Time P PSPACE EXPTIME P EXPTIME 7

The Traveling Salesman Problem You re selling fair trade coffee beans. Start at Dean s Beans World Headquarters in Dublin. Visit (in any order): Long s Bookstore, 1610 High St, Cup of Joe, Easton Town Center, 446 Lane, Court House. Drop off the leftovers in Dublin. Can you do all deliveries in one hour? What order should you use? 8

The Naïve Solution to TSP The naïve method of solving TRAVELING-SALESMAN: List all possible orderings of the cities. Find the shortest ordering. Check if it requires under one hour. So TRAVELING-SALESMAN is in EXPTIME. 16 cities: more orderings than the size of the US national debt. 63 cities: more orderings than atoms in the known universe. Can we do better? 9

Can we solve TSP efficiently?? Nobody has been able to: give a faster solution to TRAVELING-SALESMAN. prove that TRAVELING-SALESMAN needs exponential time. So TRAVELING-SALESMAN might be in P! But notice: For a particular ordering of the coffeeshops, it s easy to check if the length of the trip is under one hour. (Just add up the times.) 10

Guess and Check Another way to measure the hardness of a language: Suppose I claim that x L (and give you an argument to try to convince you). How hard is it to check if my argument is right? For example, for TETRIS: given g, s I tell you all the moves m that I ll make in the game. You check if moves m clear the gameboard g using piece sequence s. 11

NP, continued A language L is in NP if I can give you an argument A and then you can check that A is right in polynomial time. NP: Nondeterministic Polynomial Time Nondeterminism: I give you an argument; you check it. For some games, like CHESS, the move sequence might be too long to check in polynomial time! Summary: L P can be decided quickly. L NP can be checked quickly. 12

Complexity Hierarchy EXPTIME Chess, Checkers PSPACE Go, Othello, Sokoban, Generalized Geography, Hex NP P Tetris, Mastermind, Minesweeper, Sliding Blocks, Traveling Salesman Jenga, I m Thinking of a Number P EXPTIME P NP PSPACE EXPTIME 13

P vs. NP We do not know which is true! NP P P P=NP One of the greatest unsolved problems in theoretical computer science (and all of mathematics!). Clay Mathematics Institute offers $1 million for solution. Is it easier to verify a correct solution to a problem than it is to solve the problem from scratch? Huge impact on cryptography, airline scheduling, factory layout, UPS truck packing, drug design, etc., etc., etc., etc. 14

NP-completeness First major step on P vs. NP problem [Cook and Levin, 1970s]: NP P An NP-complete problem: 1. is in NP 2. is as hard as the hardest problem in NP. If we can quickly decide one NP-complete problem, then we can quickly decide them all. (P=NP) If any problem is in NP and not P, then every NP-complete problem is in NP and not P. (P NP) 15

Technique #1: Divine Inspiration Theorem [Cook/Levin]: SATISFIABILITY is NP-complete. 16

Technique #1: SAT is NP-complete SATISFIABILITY = { formulas φ : there is a way of setting the variables of φ so that φ is true } e.g., x ( x y) SATISFIABILITY. (set x := true and y := false) Theorem [Cook/Levin]: SATISFIABILITY is NP-complete. 16

Technique #2: Reduction A reduction f is a mapping from one problem to another. A f B x A if and only if f(x) B. f We re interested in efficient f. If there s a quick algorithm for B, then there s one for A. If there s no quick algorithm for A, then there s none for B. B is as hard as A 17

NP-Completeness Summary Theorem: SATISFIABILITY is NP-complete. Cook/Levin. Theorem: If: (1) A is NP-complete, (2) B is in NP, and (3) there is an efficient reduction from A to B then B is NP-complete. Karp. 18

Enough already! I came for the Tetris... To show that TETRIS is NP-complete: Define efficient mapping m from instances of known NP-Complete problem L to TETRIS. Show that if x L, then m(x) TETRIS. Show that if x/ L, then m(x) / TETRIS. 19

From 3-PARTITION to TETRIS 3-PARTITION = {sets of integers that can be separated into piles of three integers each, where each pile has the same sum} Theorem [Garey and Johnson]: 3-PARTITION is NP-complete. Our result: There is an efficient reduction from 3-PARTITION to TETRIS. 20

Our Reduction... Given integers a 1,...,a 3s and the target sum T for each pile: a 1 initiator: filler (a 1 times): terminator: 6T + 22... a 2 a 3s initiator:...... terminator: 6s +3 Finally: s,, and ( 3T 2 + 5). 21

Reminder: NP-Completeness To show that Tetris is NP-complete: Define efficient mapping m from instances of 3-PARTITION to TETRIS. Show that if x 3-PARTITION, then m(x) TETRIS. Show that if x/ 3-PARTITION, then m(x) / TETRIS. 22

For x L, we need m(x) TETRIS Yes means yes. If we have x 3-PARTITION, then need m(x) TETRIS. Pile the integers according to their 3-PARTITION piles.. 23

The yes case, continued Piles each have the same sum, so they have the same height: Each bucket is filled exactly to the top. Remaining pieces will exactly clear entire gameboard. 24

Reminder: NP-Completeness To show that TETRIS is NP-complete: Define efficient mapping m from instances of 3-PARTITION to TETRIS. Show that if x 3-PARTITION, then m(x) TETRIS. Show that if x/ 3-PARTITION, then m(x) / TETRIS. 25

Why this reduction? We want to make sure that no means no. can t clear any rows until the.... have to completely fill each bucket or it s all over. notches make it easy to get stuck. 26

For x/ L, we need m(x) / TETRIS No means no. Step #1: if you don t (or can t) make the moves from two slides ago, you get into one of the following configurations. Step #2: if you get into one of these, you re hosed. α not div. by 4 α 27

Reminder: NP-Completeness To show that Tetris is NP-complete: Define efficient mapping m from instances of 3-PARTITION to TETRIS. Show that if x 3-PARTITION, then m(x) TETRIS. Show that if x/ 3-PARTITION, then m(x) / TETRIS. Theorem: TETRIS is NP-complete. 28

Statement of Results Our results actually apply for some other Tetris questions, too: can we clear at least k rows? can we place at least p pieces without losing? can we place all pieces without filling a square at height h? can we achieve at least t tetrises? All of these are NP-complete. 29

Other Objectives and Inapproximability Can strengthen our results further: add a boatload of pieces to our sequence. Can get into (and clear) lower reservoir (using extra pieces) only if can clear the top using original. Choosing a large reservoir yields inapproximability results. 30

Other Work on Tetris Theorem: A (sufficiently long) alternating sequence of s and s will cause a loss. [Brzustowski/Burgiel] Implies that probability of a real Tetris game lasting infinitely long is zero (regardless of player s skill). On the Tetris gameboard that you know and love. (Our complexity results are as the gameboard grows.) 31

Conclusion and Open Questions Many interesting problems are NP-complete. (Traveling Salesman, Minesweeper, Tetris, Satisfiability,...) So what? Does P = NP? Is it easier to verify that a solution is correct than it is to come up with it from scratch? Games are interesting because they re hard (?) Easy way to make a million bucks: give an efficient algorithm for TETRIS! 32

Recap: Proving Membership in NP SATISFIABILITY = { formula φ : there is a way of setting the variables of φ so that φ is true } Certificate: assignment to variables Verifier: plugs in assignment and tests that φ is true 33

Recap: Proving Membership in NP SATISFIABILITY = { formula φ : there is a way of setting the variables of φ so that φ is true } Certificate: assignment a to variables Verifier: tests that φ is true with assignment a CLIQUE = { graph G and integer k : there is a clique of size k in G} Certificate: nodes in the clique C Verifier: tests that each node in C is connected to every other node in C 34

Recap: Optimization vs Decision SATISFIABILITY = { formula φ : there is a way of setting the variables of φ so that φ is true } Suppose P = NP. How can you find a satisfying assignment in polynomial time? 35

Recap: Optimization vs Decision CLIQUE = { graph G and integer k : there is a clique of size k in G} Suppose P = NP. How can you find a k-clique in polynomial time? 36