P ≠ NP? — For Dummies
Understanding a million-dollar problem with apples, pears and a little common sense.
P ≠ NP?For more than 50 years, mathematicians and computer scientists have been trying to answer a seemingly simple question:
Is P equal to NP?
The Clay Mathematics Institute offers one million dollars for the answer.
Before trying to collect the money, however, we should probably understand the question.
And for that, we need some apples and pears.
A box of fruit
Imagine a box containing apples and pears.
Our first task is simple: determine whether the box contains more apples than pears.
We count the apples, count the pears and compare the two numbers.
If the box contains ten pieces of fruit, we need ten inspections. If it contains a million, we need a million.
Double the number of fruits and we double the amount of work.
Computer scientists describe this as O(n), where n represents the number of fruits.
This brings us to our first mathematical concept.
What is polynomial time?
Polynomial time describes how the computational effort grows as a problem becomes larger.
Imagine three different tasks:
- Inspect every fruit once: n operations.
- Compare every fruit with every other fruit: approximately n² operations.
- Examine every possible selection of fruits: 2ⁿ combinations.
With 100 fruits, the first task requires 100 inspections, the second approximately 10,000 comparisons.
The third involves approximately 1,267,650,600,228,229,401,496,703,205,376 possible selections.
The first two grow polynomially. The third grows exponentially.
Any computational effort bounded by n raised to a fixed power is considered polynomial.
This includes n², n³ and even n¹⁰⁰.
Polynomial does not necessarily mean fast. It describes how computational effort grows, not how long we actually have to wait.
P — Problems we can solve
Our first fruit problem belongs to a mathematical class called P.
P stands for Polynomial Time.
It contains decision problems — questions with a yes or no answer — that can be solved in polynomial time.
Are there more apples than pears?
We know how to answer that question, and the computational effort grows polynomially.
So far, so good.
NP — Solutions we can verify
Now let us make our fruit problem more interesting.
We have fruits of different weights:
🍎 120 grams, 🍐 150 grams, 🍎 90 grams, 🍐 180 grams,
🍐 210 grams, 🍎 140 grams, 🍎 110 grams, 🍐 130 grams
Our question is:
Is there a selection of fruits that weighs exactly 500 grams?
We could try every possible combination.
With eight fruits, that is manageable. With hundreds of fruits, it becomes considerably more challenging.
But imagine someone hands us the following solution:
🍎 120 + 🍐 150 + 🍎 90 + 🍎 140 = 500
We can verify the answer immediately.
Finding the solution and verifying the solution are two fundamentally different tasks.
The general version of this problem, in which the weights and target can vary, is known as Subset Sum.
It belongs to NP.
NP stands for Nondeterministic Polynomial Time. For our purposes, it is sufficient to understand that a proposed solution establishing a yes answer can be verified in polynomial time.
And no, NP does not stand for Non-Polynomial.
The million-dollar question
Every P problem also belongs to NP.
After all, if we can solve a problem in polynomial time, we can also check a proposed solution in polynomial time.
But does this work the other way around?
If we can verify a solution in polynomial time, can we also find one in polynomial time?
If the answer is yes, then P = NP.
If the answer is no, then P ≠ NP.
That is the million-dollar question.
But there is another question that puzzled me considerably more.
How can we possibly answer this for every conceivable NP problem?
There are infinitely many of them.
The universal problem
In 1971, Stephen Cook and Leonid Levin independently established a remarkable mathematical result.
Certain problems within NP have a special property: every other NP problem can be converted into them in polynomial time.
These are called NP-complete problems.
Examples include:
- Boolean satisfiability (SAT)
- Subset Sum
- Generalized Sudoku
- Three-color graph coloring
- The decision version of the Traveling Salesman Problem
At first glance, these problems appear to have very little in common.
What does selecting fruits have to do with solving Sudoku?
Yet mathematically, we can convert these problems into one another.
We can even translate a Sudoku puzzle into an appropriately constructed version of our fruit problem.
The conversion does not solve the problem. It simply reformulates it.
Think of a compiler
As a software developer, I find the following analogy helpful.
We can write software in C, Pascal or COBOL and translate these different languages into machine code.
The processor does not need to understand every programming language. It executes a common representation.
Something similar happens with NP-complete problems.
Different NP problems can be translated into a common mathematical problem, such as SAT.
And here comes the remarkable part:
We already know that the translation can be performed in polynomial time.
What we do not know is whether the resulting problem can always be solved in polynomial time.
One solver to solve them all
We do not need to invent a separate polynomial-time algorithm for Sudoku, Subset Sum and every other NP problem.
We only need one for a single NP-complete problem.
We could then convert every other NP problem into that problem and solve it.
P = NP? is essentially the question of whether a universal NP-problem solver with polynomial running time can exist.
That is what mathematicians have been investigating for more than 50 years.
If someone discovers such an algorithm, P = NP is established.
If someone proves that such an algorithm cannot exist, P ≠ NP is established.
Coming next: VP ≠ VNP?
Now that we understand P and NP, we can move on to another fascinating question in computational complexity.
In 1979, Leslie Valiant introduced a related but fundamentally different mathematical problem: VP versus VNP.
While P versus NP concerns the efficiency of solving problems, Valiant investigates the limits of algebraic shortcuts.
To understand his question, we will leave our apples and pears behind and revisit a famous mathematical shortcut associated with the young Carl Friedrich Gauss.
But first, another cup of coffee.
Further reading
