Ian Stewart's article "Million-Dollar Minesweeper"

Similar documents
CS 350 Algorithms and Complexity

CS 350 Algorithms and Complexity

10.3: Intractability. Overview. Exponential Growth. Properties of Algorithms. What is an algorithm? Turing machine.

Computational Complexity

Minesweeper is NP-Complete

2 n Minesweeper Consistency Problem is in P

P, NP, NP-Complete. Ruth Anderson

Announcements. Friday Four Square! Problem Set 8 due right now. Problem Set 9 out, due next Friday at 2:15PM. Did you lose a phone in my office?

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

CSCI3390-Lecture 17: A sampler of NP-complete problems

Notes for Lecture 21

Classes of Problems. CS 461, Lecture 23. NP-Hard. Today s Outline. We can characterize many problems into three classes:

The Inductive Proof Template

Checkpoint Questions Due Monday, October 1 at 2:15 PM Remaining Questions Due Friday, October 5 at 2:15 PM

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Limitations of Algorithms

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

The Game of Cubic is NP-complete Erich Friedman Stetson University

Recap from Last Time

The P = NP Problem Bristol Teachers Circle, June P.D.Welch, University of Bristol

Algorithms: COMP3121/3821/9101/9801

NP-Completeness. Until now we have been designing algorithms for specific problems

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

1 Reductions and Expressiveness

NP Complete Problems. COMP 215 Lecture 20

7.8: Intractability. Overview. Exponential Growth. Properties of Algorithms. What is an algorithm? Turing machine.

The complexity of Minesweeper and strategies for game playing. Kasper Pedersen

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

Lecture 15 - NP Completeness 1

Chapter 1: Logic systems

CSCI3390-Lecture 18: Why is the P =?NP Problem Such a Big Deal?

NP-complete problems. CSE 101: Design and Analysis of Algorithms Lecture 20

Topics in Complexity

Lecture 24: How to become Famous with P and NP

NP-Completeness Review

MITOCW R11. Double Pendulum System

Limitations of Algorithm Power

INTRO TO COMPUTATIONAL COMPLEXITY

Recap from Last Time

Algorithm Design and Analysis

VIDEO Intypedia008en LESSON 8: SECRET SHARING PROTOCOL. AUTHOR: Luis Hernández Encinas. Spanish Scientific Research Council in Madrid, Spain

Lesson 6: Algebra. Chapter 2, Video 1: "Variables"

1.1 P, NP, and NP-complete

ECS 120 Lesson 24 The Class N P, N P-complete Problems

NP-Completeness Part II

Lecture 14 - P v.s. NP 1

CSC 421: Algorithm Design & Analysis. Spring 2018

P vs. NP. Data Structures and Algorithms CSE AU 1

Chapter Finding parse trees

DESIGN AND ANALYSIS OF ALGORITHMS. Unit 6 Chapter 17 TRACTABLE AND NON-TRACTABLE PROBLEMS

Unit 6 Chapter 17 TRACTABLE AND NON-TRACTABLE PROBLEMS

Algorithm Design and Analysis

Complexity Theory Part II

MITOCW ocw f99-lec01_300k

CS103 Handout 09 Fall 2012 October 19, 2012 Problem Set 4

Artificial Intelligence. 3 Problem Complexity. Prof. Dr. Jana Koehler Fall 2016 HSLU - JK

15-451/651: Design & Analysis of Algorithms October 31, 2013 Lecture #20 last changed: October 31, 2013

NP-Completeness Part One

Introduction to Complexity Theory

Instructor N.Sadagopan Scribe: P.Renjith. Lecture- Complexity Class- P and NP

MITOCW ocw f99-lec09_300k

arxiv: v1 [cs.cc] 1 Feb 2016

MITOCW ocw f99-lec05_300k

Harvard CS 121 and CSCI E-121 Lecture 22: The P vs. NP Question and NP-completeness

4/19/11. NP and NP completeness. Decision Problems. Definition of P. Certifiers and Certificates: COMPOSITES

THE SIMPLE PROOF OF GOLDBACH'S CONJECTURE. by Miles Mathis

A Note on Turing Machine Design

Chapter 2. Reductions and NP. 2.1 Reductions Continued The Satisfiability Problem (SAT) SAT 3SAT. CS 573: Algorithms, Fall 2013 August 29, 2013

COP 4531 Complexity & Analysis of Data Structures & Algorithms

NP and NP Completeness

3: Linear Systems. Examples. [1.] Solve. The first equation is in blue; the second is in red. Here's the graph: The solution is ( 0.8,3.4 ).

SAT, NP, NP-Completeness

MITOCW ocw f99-lec17_300k

Principles of Computing, Carnegie Mellon University. The Limits of Computing

Nondeterministic Turing Machines

CS103 Handout 08 Spring 2012 April 20, 2012 Problem Set 3

On the Computational Hardness of Graph Coloring

A Working Knowledge of Computational Complexity for an Optimizer

MITOCW ocw-18_02-f07-lec02_220k

CSC 1700 Analysis of Algorithms: P and NP Problems

NP-Complete Problems. More reductions

Direct Proof and Counterexample I:Introduction

4/22/12. NP and NP completeness. Efficient Certification. Decision Problems. Definition of P

Direct Proof and Counterexample I:Introduction. Copyright Cengage Learning. All rights reserved.

Some unsolved problems in mathematics and computation

NP-completeness. Chapter 34. Sergey Bereg

COMP Analysis of Algorithms & Data Structures

Week 2: Defining Computation

Instructor N.Sadagopan Scribe: P.Renjith

6: Polynomials and Polynomial Functions

DIFFERENTIAL EQUATIONS

The Beauty and Joy of Computing

6.080/6.089 GITCS Apr 15, Lecture 17

Lecture Notes Each circuit agrees with M on inputs of length equal to its index, i.e. n, x {0, 1} n, C n (x) = M(x).

intro to the theory of computation

Limits of Computation. Antonina Kolokolova

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Note 1

Guide to Negating Formulas

P, NP, NP-Complete, and NPhard

Algorithms and Theory of Computation. Lecture 22: NP-Completeness (2)

Transcription:

Page 1 of 5 Million-Dollar Minesweeper Lecture: November 1, 2000 (Video Online) Ian Stewart, Department of Mathematics, University of Warwick, UK It's not often you can win a million dollars by analysing a computer game, but by a curious conjunction of fate, there's a chance that you might. However, you'll only pick up the loot if all the experts are wrong and a problem that they think is extraordinarily hard turns out to be easy. So don't order the Corvette yet. The prize is one of seven now on offer from the newly founded Clay Mathematics Institute in Cambridge MA, set up by businessman Landon T. Clay to promote the growth and spread of mathematical knowledge, each bearing a million-buck price-tag. The computer game is Minesweeper, which is included in Microsoft's Windows operating system, and involves locating hidden mines on a grid by making guesses about where they are located and using clues provided by the computer. And the problem is one of the most notorious open questions in mathematics, which rejoices in the name 'P=NP?'. The connection between the game and the prize problem was explained by Richard Kaye of the University of Birmingham, England ('Minesweeper is NP-complete', Mathematical Intelligencer volume 22 number 4, 2000, pages 9-15). And before anyone gets too excited, you won't win the prize by winning the game. To win the prize, you will have to find a really slick method to answer questions about Minesweeper when it's played on gigantic grids and all the evidence suggests that there isn't a slick method. In fact, if you can prove that there isn't one, you can win the prize that way too. Let's start with Minesweeper. The computer starts the game by showing you a blank grid of squares. Some squares conceal mines; the rest are safe. Your task is to work out where the mines are without detonating any of them. You do this by choosing a square. If there's a mine underneath it, the mine is detonated and the game ends--- with a loss for you, of course. If there is no mine, however, the computer writes a number in that square, telling you how many mines there are in the eight immediately adjacent squares (horizontally, vertically, and diagonally). If your first guess hits a mine, you're unlucky: you get no information except that you've lost. If it doesn't, though, then you get partial information about the location of nearby mines. You use this information to influence your next choice of square, and again either you detonate a mine and lose, or you gain information about the positions of nearby mines. If you wish, you can choose to mark a square as containing a mine: if you're wrong, you lose. Proceeding in this way, you can win the game by locating and marking all the mines.

Page 2 of 5 Fig.1 A Typical Minesweeper Position For instance, after a few moves you might reach the position shown in Fig.1. Here a flag shows a known mine (position already deduced), the numbers are the information you've gotten from the computer, and the letters mark squares whose status is as yet untested. With a little thought, you can deduce that the squares marked A must contain mines, because of the 2's just below them. The squares marked B must also contain mines, because of the 4's and 5's nearby. In the same way, C must contain a mine; and it then follows that D and E do not. The status of F can then be deduced, after a few moves, by uncovering D and seeing what number appears. Now, the P=NP? problem. Recall that an algorithm is a procedure for solving some problem that can be run by a computer: every step is specified by some program. A central question in the mathematics of computation is: how efficiently can an algorithm solve a given problem? How does the running time--- the number of computations needed to get the answer--- depend on the initial data? For theoretical purposes the main distinction is between problems that are of type P--- polynomial time --- and those that are not. A problem is of type P if it can be solved using an algorithm whose running time grows no faster than some fixed power of the number of symbols required to specify the initial data. Otherwise the problem is non-p. Intuitively, problems in P can be solved efficiently, whereas non-p problems cannot be solved algorithmically in any practical manner because any algorithm will take a ridiculously long time to get an answer. Problems of type P are easy, non-p problems are hard. Of course it's not quite as simple as that, but it's a good rule of thumb. You can prove that a problem is of type P by exhibiting an algorithm that solves it in polynomial time. For example, sorting a list of numbers into numerical order is a type P problem, which is why commercial databases can sort data; and searching a string for some sequence of symbols is also a type P problem, which is why commercial wordprocessors can carry out search-and-replace operations. In contrast, the Travelling Salesman Problem--- find the shortest route whereby a salesman can visit every city on some itinerary--- is widely believed to be non-p, but this has never been proved. Finding the prime factors of a given integer is also widely believed to be non-p, too, but this has never been proved either. The security of certain cryptosystems, some of which are used to send personal data such as credit card numbers over the Internet, depends upon this belief being correct. Why is it so hard to prove that a problem is non-p? Because you can't do that by analysing any particular algorithm. You have to contemplate all possible algorithms and show that none of them can solve the problem in polynomial time. This is a mindboggling task. The best that has been done to date is to prove that a broad class of candidate non-p problems are all on the same footing--- if any one of them can be

Page 3 of 5 solved in polynomial time, then they all can. The problems involved here are said to have 'nondeterministic polynomial' running time: type NP. NP is not the same as non-p. A problem is NP if you can check whether a proposed solution actually is a solution in polynomial time. This is --- or at least, seems to be --- a much less stringent condition than being able to find that solution in polynomial time. My favourite example here is a jigsaw puzzle. Solving the puzzle can be very hard, but if someone claims they've solved it, it usually takes no more than a quick glance to check whether they're right. To get a quantitative estimate of the running time, just look at each piece in turn and make sure that it fits the limited number of neighbours that adjoin it. The number of calculations required to do this is roughly proportional to the number of pieces, so the check runs in polynomial time. But you can't solve the puzzle that way. Neither can you try every potential solution in turn and check each as you go along, because the number of potential solutions grows much faster than any fixed power of the number of pieces. It turns out that a lot of NP problems have 'equivalent' running times. Specifically, an NP problem is said to be NP-complete if the existence of a polynomial time solution for that problem implies that all NP problems have a polynomial time solution. Solve one in polynomial time, and you've solved them all in polynomial time. A vast range of problems are known to be NP-complete. The P=NP? problem asks whether types P and NP are (despite all appearances to the contrary) the same. The expected answer is 'no'. However, if any NP-complete problem turns out to be of type P--- to have a polynomial time solution--- than NP must equal P. We therefore expect all NPcomplete problems to be non-p, but no one can yet prove this. One of the simplest known NP-complete problems is SAT, the logical satisfiability of a Boolean condition. Boolean circuits are built from logic gates with names like AND, OR and NOT. The inputs to these circuits are either T (true) or F (false). Each gate accepts a number of inputs, and outputs the logical value of that combination. For instance an AND gate takes inputs p, q and outputs p AND q, which is T provided p and q are both T, and F otherwise. A NOT gate turns input T into output F and input F into output T. The SAT problem asks, for a given Boolean circuit, whether there exist choices of inputs that produce the output T. If this sounds easy, don't forget that a circuit may contain huge numbers of gates and have huge numbers of inputs. Fig.2 Impossible Minesweeper position. The link to the computer game comes when we introduce the Minesweeper Consistency Problem. This is not to find the mines, but to determine whether a given state of what purports to be a Minesweeper game is or is not logically consistent. For example, if during the state of play you encountered Fig.2, you would know that the programmer had made a mistake: there is no allocation of mines consistent with the information shown. Kaye proves that Minesweeper is equivalent to SAT, in the following sense. The SAT problem for a given Boolean circuit can be 'encoded' as a Minesweeper Consistency Problem for some position in the game, using a code procedure that runs in polynomial time. Therefore, if you could solve the Minesweeper

Page 4 of 5 Consistency Problem in polynomial time, you would have solved the SAT problem for that circuit in polynomial time. In other words, Minesweeper is NP-complete. So, if some bright spark finds a polynomial-time solution to Minesweeper, or alternately proves that no such solution exists, then the P=NP? problem is solved (one way or the other). Fig.3 A Minesweeper wire. Kaye's proof involves a systematic procedure for converting Boolean circuits into Minesweeper positions. Here a grid square has state T if it contains a mine, and F if not. The first step involves not gates, but the wires that connect them. Fig.3 shows a Minesweeper wire. All squares marked x either contain a mine (T) or do not contain a mine (F), but we don't know which. All squares marked x' do the opposite of x. You should check that all the numbers shown are correct whether x is T or F. The effect of the wire is to 'propagate' the signal T or F along its length, ready to be input into a gate. Fig.4 shows a NOT gate. The numbers marked on the block in the middle force an interchange of x and x' on the exit wire, compared to the input wire. Fig.4 The NOT gate. The AND gate (Fig. 5) is more complicated. Fig. 5 The AND gate. It has two input wires U, V, and one output W. To establish that this is an AND gate, we assume that the output is T and show that both inputs have to be T as well. Since the output is T, every symbol t must indicate a mine and every t' a non-mine. Now the 3 above and below a3 implies that a2 and a3 are mines, so a1 is not a mine, so s is a mine. Similarly, r is a mine. Then the central 4 already has four mines as neighbours, which implies that u' and v' are non-mines, so u and v are mines--- and this means that

Page 5 of 5 U and V have truth-value T. Conversely, if U and V have value T then so does W. In short, we have an AND gate as claimed. There's more to Minesweeper electronics than this--- for example, we need to be able to bend wires, split them, join them, or make them cross without connecting. Kaye solves all these problems, and other more subtle ones, in his article. The upshot is that solving the Minesweeper Consistency Problem is algorithmically equivalent to the SAT problem, and is thus NP-complete. To virtually every mathematician and computer scientist, this means that the Minesweeper Consistency Problem must be inherently hard. It is astonishing that such a simple game should have such intractable consequences, but mathematical games are like that. If you're interested in those million-dollar prizes, a word of warning. The Clay Institute imposes strict rules before it will accept a solution as being valid. In particular, it must be published by a major refereed journal, and it must have been 'generally accepted' by the mathematical community within two years of publication. But even if you're not going to tackle anything as daunting as that, you can have a lot of fun playing Minesweeper, secure in the knowledge that it encompasses one of the great unsolved problems of our age. Authoritative Minesweeper thanks Ian Stewart for permission to host this article. The original article appeared 1 Nov 2000 as one of seven popular lectures sponsored by the Clay Mathematics Institute. Richard Kaye at the University of Birmingham discovered Minesweeper to be NP-complete, his work being published as "Minesweeper is NP-complete" in The Mathematical Intelligencer, 22(2):9--15, Spring 2000.