Why are some computational problems so hard and others easy? This
may sound like a childish, whining question, to be dismissed
with a shrug or a wisecrack, but if you dress it up in the
fancy jargon of computational complexity theory, it becomes
quite a serious and grownup question: Is P equal to NP? An
answer—accompanied by a proof—will get you a
million bucks from the Clay Mathematics Institute.
I'll
return in a moment to P and NP, but first an example, which
offers a glimpse of the mystery lurking beneath the surface of
hard and easy problems. Consider a mathematical graph, a
collection of vertices (represented by dots) and edges
(lines that connect the dots). Here's a nicely symmetrical
example:
Is it possible to construct a path that traverses each edge
exactly once and returns to the starting point? For any
graph with a finite number of edges, we could answer such a
question by brute force: Simply list all possible paths and
check to see whether any of them meet the stated conditions.
But there's a better way. In 1736 Leonhard Euler proved that
the desired path (now called an Eulerian circuit) exists if
and only if every vertex is the end point of an even number
of edges. We can check whether a graph has this property
without any laborious enumeration of pathways.
Now take
the same graph and ask a slightly different question: Is
there a circuit that passes through every vertex
exactly once? This problem was posed in 1858 by William
Rowan Hamilton, and the path is called a Hamiltonian
circuit. Again we can get the answer by brute force. But in
this case there is no trick like Euler's; no one knows any
method that gives the correct answer for all graphs and does
so substantially quicker than exhaustive search.
Superficially, the two problems look almost identical, but
Hamilton's version is far harder. Why? Is it because no shortcut
solution exists, or have we not yet been clever enough to find
one?
Most computer scientists and mathematicians believe
that Hamilton's problem really is harder, and no shortcut
algorithm will ever be found—but that's just a
conjecture, supported by experience and intuition but not by
proof. Contrarians argue that we've hardly begun to explore
the space of all possible algorithms, and new
problem-solving techniques could turn up at any time. Before
1736, the Eulerian-circuit problem also looked hard.
What prompts me to write on this theme is a new and wholly
unexpected family of algorithms that provide efficient methods
for several problems that previously had only brute-force
solutions. The algorithms were invented by Leslie G. Valiant
of Harvard University, with extensive further contributions
by Jin-Yi Cai of the University of Wisconsin. Valiant named
the methods "holographic algorithms," but he also
refers to them as "accidental algorithms,"
emphasizing their capricious, rabbit-from-the-hat quality;
they seem to pluck answers from a tangle of unlikely
coincidences and cancellations. I am reminded of the famous
Sidney Harris cartoon in which a long series of equations on
a blackboard hinges on the notation "Then a miracle
occurs."