P versus NP for dummies

Okay, let's see if I can correctly interpret scripture.

Algorithmic complexity

Firstly, you probably already know what big O notation is. To put it in very simple terms, big O notation is a way to express the computational complexity of an algorithm. An algorithm is a straightforward method or sequence of instructions for solving a particular set of problems.

A great example of an algorithm is the pen-and-paper method of long multiplication. You learned this in primary school so I won't patronise you by rehearsing the steps, but here's a worked example:

     42
 x   64
--------
    168
 + 252
--------
   2688
--------

Notice how this involves a total of four separate multiplications and then three more addition steps to determine the final answer. Notice also how the total number of steps (multiplications and additions and so on) is dependent on the size of the numbers you are multiplying. Multiplying two single-digit numbers takes just one step, because you have the result memorised. Multiplying a two-digit number with a one-digit number takes two multiplication steps (one for each digit) and one addition step to put those two results together. (Addition itself can be broken down into further steps as well.)

The point is that long multiplication is an algorithm which is equally useful for multiplying any pair of integers. The only difference is the number of steps the algorithm takes. In general, the number of steps scales with the number of digits. If the first integer has m digits and the second integer has n digits, the number of individual multiplication steps required is of order O(mn). This is the time complexity of the algorithm (assuming that each step takes the same amount of time to complete).

Often, multiple algorithms may be applicable to the same problem or set of problems. Selecting the best algorithm for a situation can be difficult, especially if you're smart enough that devising an entirely new, more efficient algorithm might be an option.

(There are also some very important sets of problems for which it has been proven that no algorithm exists at all. These problem sets are called undecidable. The name is misleading: just because a set of problems has been deemed generally undecidable doesn't mean that any specific problem within that set is unsolvable.)

Automata

When I said "straightforward sequence of instructions" above, what I really meant was "computer program". And by "computer" what I mean is an idealised mathematical model of a computer called an automaton. Automata come in varying degrees of capability, starting from very simple machines which can only implement very simple algorithms, ranging up to full-blown Turing machines which can implement basically any algorithm.

This is where the notions of "step" and "time" become important. The computational complexity of an algorithm is based directly on the number of steps it would take a Turing machine to work the algorithm all the way through.

P

P is defined as the set of all decision problems for which an algorithm exists which can be carried out by a deterministic Turing machine in polynomial time.

Your computer is a deterministic Turing machine.

A sample set of problems falling in P is "Is n prime?"

NP

NP is defined as the set of all decision problems for which an algorithm exists which can be carried out by a nondeterministic Turing machine in polynomial time.

A nondeterministic Turing machine is like a conventional Turing machine, but at any given step during computation it can do more than one thing at once. At this point it effectively bifurcates (multifurcates?), becoming multiple Turing machines simultaneously computing multiple possibilities. As computation continues, a nondeterministic Turing machine can split many times, calculating a vast number of possibilities simultaneously.

There is no computer in the world which qualifies as a true nondeterministic Turing machine. With some minor ifs and buts, nondeterministic Turing machines are a purely abstract concept and can't exist in reality.

A sample set of problems falling in NP is "What integers between 1 and q are prime?"

A nondeterministic Turing machine can do multiple things at once. So, a nondeterministic Turing machine can check every n between 1 and q at once, in the same amount of time that a deterministic Turing machine would take to check just one value of n.

Does P equal NP?

Clearly, any nondeterministic Turing machine can masquerade as a deterministic Turing machine by simply not splitting at any step. So, any problem solvable by a deterministic Turing machine in polynomial time is also solvable by a nondeterministic Turing machine in polynomial time. Thus, PNP.

(It is also true, though harder to prove, that a deterministic Turing machine can be made which emulates the behaviour of any nondeterministic Turing machine. However, this requires the nondeterministic Turing machine's algorithm to be modified. This modification will almost certainly make the algorithm slower in absolute terms, and probably increase its algorithmic complexity from polynomial time to something larger.)

However, this doesn't tell us whether the two are equal or not. While nondeterministic Turing machines appear to be vastly more powerful than deterministic Turing machines, this is neither obvious nor proven. In order to prove that PNP, we would need to prove that there exists a set of problems X such that:

  1. X falls in NP. There exists an algorithm with which a nondeterministic Turing machine could solve problems in X in polynomial time.
  2. X does not fall in P. There exists no algorithm whatsoever with which a deterministic Turing machine could solve problems in X in polynomial time.

NOTE: we just have to prove that X exists (a non-constructive proof)! We don't have to actually find it (a constructive proof), though this would be nice!

While it is widely suspected that PNP, until this is proven nobody can say for sure.

Why is this important?

The most important sample problem set in P is "Is X the correct decryption key for this encrypted file?" Obviously, checking to see whether a key is correct for an encrypted file is a very straightforward process, otherwise we would be sitting around all day waiting for things to fully decrypt.

However, this has a corresponding problem in NP which is "Which of all the possible decryption keys for this encrypted file is the correct one?" In the same amount of time that a deterministic Turing machine takes to check one key, a nondeterministic Turing machine running the exact same algorithm could check every single key simultaneously and tell you the correct one.

Now, as I mentioned, nondeterministic Turing machines are fictitious. Only deterministic Turing machines exist in reality. A deterministic Turing machine can always pretend to be an nondeterministic Turing machine (i.e. a brute-force systematic search of every possible key, one after the other), but only by modifying the algorithm to work in exponential time, which is almost always much less favourable than polynomial time. In other words, breaking open an encrypted file is extremely difficult.

But if P = NP, then for every polynomial-time nondeterministic Turing machine, such as our fictitious instantaneous code-breaker, we would know that there also exists a polynomial-time deterministic Turing machine, possibly with a less favourable polynomial but with the exact same functionality. We would know that checking every single key simultaneously can be done in polynomial time. In other words, breaking open an encrypted file would be very easy.

Now, most people are of the opinion that this is not the case. But again, until it's proven, nobody can say for sure.

Back to Blog
Back to Things Of Interest
StumbleUpon Twitter Hacker News Facebook Reddit Digg del.icio.us Email

Discussion (11)

2010-08-09 21:17:50 by Snowyowl:

For the record, in the official P=NP problem statement, the complexity of the problem is defined as the number of bits used to describe the input. In the case of your multiplication problem, this means you can solve it in O(n) time.

(Well, bits... for P=NP you can write it in decimal digits if you like, it makes no difference.)

2010-08-11 16:02:11 by DaveA:

What is the reasoning behind allowing comments for some posts and not others?

I wanted to make a suggestion on your FTL entry but couldn't.

If you're interested in forward looking real engineering sci-fi, the coolest subject would be in the realm of the first real Machine Intelligence.

Humans struggle to fathom the physics of this universe. Our attention span is low, we get tired, we have limited memory, we're slow. How to figure out the solution to what's really going on at the bottom level of this universe? Create a Machine Intelligence and let <i>it</i> figure it out.

MI is the last problem humans will need to solve. And the only one worth solving. Because it in itself solves all the rest.

2010-08-11 16:24:45 by Sam:

"FTL entry"?

2010-08-11 17:15:09 by DaveA:

"FTL entry"

http://qntm.org/ftl

2010-08-11 17:29:58 by Sam:

Okay. Well, the reason I disabled comments on that entry was that I wasn't particularly looking for feedback on it. You've kind of twice defeated the comments system, firstly by providing feedback on an entry where no feedback was solicited and secondly by putting feedback on an entry under a completely different and unrelated entry. So, well done, I guess?

2010-08-11 17:38:35 by DaveA:

Regarding feedback:

How can you be certain you don't want feedback? The whole idea of feedback is to expose yourself to something unexpected.

Lately as regards myself I've realized I'm thinking in ruts. The same thoughts over and over again. No breakthroughs. How to get out of the rut? The answer is, modify my life to allow for the Unexpected to occur.

This is why old people never innovate. They surround themselves with a nice, soft, warm, cozy environment where nothing unexpected ever comes up. Then they themselves become zombies.

Note I'm not trying to hack your comments machinery. I'm just interested in some interaction on some of your topics of interest.

I'm amazed at the sheer volume of your creative output. How do you maintain your motivation?

2010-08-12 13:19:07 by Snowyowl:

Ahem, breaking news:
P VERSUS NP HAS BEEN SOLVED!

(The proof hasn't been peer-reviewed yet though. It might still be wrong.)
Yesterday, a paper was published concerning the conjunctive Boolean satisfiability problem, which asks whether a given list of logical statements contradict each other or not. This is an NP-complete problem, but the paper at www.hpl.hp.com/personal/Vinay_Deolalikar/Papers/pnp12pt.pdf asserts that it cannot be solved in polynomial time.

If, like me, you don't want to read all 100-plus pages of that PDF, New Scientist has a relevant article at http://www.newscientist.com/article/dn19287

I thought you should be the first to know. Facebook is second.

2010-08-12 15:38:52 by Sam:

I heard about that a week ago! Why do you think I wrote this essay in the first place?

2010-08-14 11:10:52 by Snowyowl:

I realised that a few minutes after posting my comment... Sorry for that.

2010-08-30 01:59:12 by ejl:

Could you, like, write more on this subject? 'Cos you do explain things pretty well :-D (I do enjoy reading your occasional writes-up on these sorts of things)

2011-09-18 22:23:55 by Justin:

I have a thought experiment. Suppose you leave Earth at .99c. You begin working on a problem while at the same time a person on Earth is working on the exact same problem. You stop your ship after you have done one step on the problem and find out that back on Earth the other person has all ready done multiple steps. Feel free to email me at midshipman01_2001@yahoo.com

add comment