Grampa's Guide to Impossible Games

Grampa's Guide to Impossible Games

P, NP, and why some games can't be beaten by brute force

1. P: the easy ones

Grampa's first rule: computer scientists don't ask "how long does this take?" They ask "what happens when the puzzle gets bigger?"

A problem is in P (short for polynomial time) when the work grows gently. Double the puzzle and the work might double, or grow 4 or 8 times. Computers shrug that off, even for huge puzzles.

The troublemakers grow exponentially: add one more piece and the work doubles. That gets out of hand shockingly fast. Slide the bar and watch.

Takeaway: P means a computer can solve it fast, even when it gets big.
From your library:

Gentle vs. explosive growth

Times assume a computer doing a billion steps a second. Bars count zeros, so each extra bit of bar means 10 times more work.

Puzzle size (n)10
Gentle (n × n): in P
Explosive (2 × 2 × 2 … n times)

Six Degrees: easy for a computer

The computer checks actors one ring at a time, nearest first. Each actor is looked at once, so even millions of actors go quickly.

Start actor is circled in red. Lines mean "were in a movie together."

2. NP: easy to check

Now the big idea. Some puzzles are hard to solve, but if somebody hands you an answer, you can check it in a snap.

That's NP: "easy to check." The letters stand for nondeterministic polynomial, a fancy way of saying "fast, if you're a lucky guesser."

Every P problem is also in NP. If you can solve it fast, you can surely check it fast.

Try the little Sudoku. Solving takes some thinking. Checking takes one quick look at each row, column and box.

Takeaway: NP means that if you're handed an answer, you can check it fast. Finding it may be another story.
From your library:

Solve it, then check it

Tap a blank square to cycle 1, 2, 3, 4. Each row, column and 2×2 box needs 1 through 4.

Fill it in, then press Check my grid.

Why solving is harder

3. NP-complete: the master keys

Among the NP puzzles, some are the toughest of the bunch. Any NP puzzle can be disguised as one of them, rewritten so that solving it answers the original.

These are NP-complete. They're master keys: find a fast method for any one, and you have a fast method for all of NP.

The first was proven in 1971, a logic puzzle called SAT. Thousands have joined since, including a lot of your games.

One catch: the proofs use "any size" versions, like a Sudoku that can grow to 16×16, 25×25 and beyond. Your fixed-size games are small enough for a computer to grind through.

Takeaway: NP-complete means the hardest problems in NP. Crack one fast, crack them all. Nobody has, in over 50 years.
From your library (tap the web for details):

The master key web

Every game here can be translated into SAT, and SAT into every game. Tap a game to see what's hard about it.

Tap any game in the web.

4. NP-hard: at least that hard

NP-hard means "at least as hard as the NP-complete puzzles." The difference is that an NP-hard problem doesn't have to be easy to check.

Take a road trip. "Find me a route under 500 miles" is NP-complete: hand me a route and I'll add up the miles. But "find me the shortest route" is NP-hard. If you hand me a route, how do I know nothing shorter exists? I'd have to compare it to all the others.

That's the famous Traveling Salesman Problem, and every road trip in Staycation bumps into it. Add towns and watch the number of routes explode.

Takeaway: NP-hard means at least as hard as NP-complete, and maybe too hard to even check.
From your library:

Plan a road trip

Tap the map to add up to 9 towns. Town 1 is home. Then have the computer try every route.

Tap the map to add towns.

Where it goes from here

5. PSPACE: when there's an opponent

Solo puzzles have one kind of answer: a solution you can check. Two-player games are different.

"Can I force a win?" really means: I have a move, so that whatever you reply, I have a move, so that whatever you reply… all the way to the end.

The proof isn't one path. It's a whole tree covering every reply. Handing somebody that tree doesn't make it quick to check.

Many games like this land in PSPACE: problems a computer can solve with a reasonable amount of memory, even if it takes a very long time. The hardest of them are PSPACE-complete.

Takeaway: PSPACE means problems that need patience but not a warehouse of memory. Two-player games often live here.
From your library:

Every reply counts

Green dots are your turns, red dots are your opponent's. The bottom row is every position you'd have to judge.

Choices per turn3
Turns ahead3

6. EXPTIME: chess, checkers and Go

Chess, checkers and Go let positions come back again and again, so a game can wander for an enormous number of moves. That pushes them past PSPACE into EXPTIME: problems that take exponential time.

On an any-size board, all three are EXPTIME-complete: chess (1981), Go with Japanese ko rules (1983) and checkers (1984).

Here's the kicker. Mathematicians have proven that these can't be solved in polynomial time. With NP-complete puzzles we only suspect they're hard. With these, we know.

Your regular boards are a special case. Checkers on 8×8 was solved in 2007. Chess and Go haven't been, so computers win by smart guessing, not by checking everything.

Takeaway: EXPTIME-complete means proven hard. No genius will ever find a shortcut for any-size chess, checkers or Go.
From your library:

How many positions?

Tap a game. Bars count zeros. The dashed line is the number of atoms in the known universe (a 1 with 80 zeros).

Tap a game above.

7. P vs. NP: the million-dollar question

Everything in P is in NP. The big question: is everything in NP also in P? Is every puzzle that's easy to check also easy to solve?

If yes (P = NP), every NP-complete puzzle has a fast method we just haven't found. If no (P ≠ NP), some puzzles are hard forever.

Since 2000, the Clay Mathematics Institute has offered $1 million for a proof either way. It's still unclaimed. Most experts bet on P ≠ NP.

Why you should care: the locks on online banking rely on math that's easy to check and hard to undo, like breaking a big number into its primes. If P = NP, those locks could be picked.

Grampa's cheat sheet:
  1. P: easy to solve.
  2. NP: easy to check.
  3. NP-complete: the hardest of NP. Crack one, crack all.
  4. NP-hard: at least that hard, maybe not even checkable.
  5. PSPACE: two-player games that need patience, not much memory.
  6. EXPTIME: chess, checkers and Go. Proven hard.
  7. P vs. NP: is easy-to-check always easy-to-solve? Worth $1 million.
From your library:

The map of hard

EXPTIME PSPACE NP P Six Degrees Word Search NP- complete Sternhalma Road trip Chess, Checkers and Go NP-hard NP-complete: Sudoku, Minesweeper, FreeCell, Tetris…
Step 1 of 7