Intractability [00UO]
- November 30, 2026
Introduction to intractability [00UP]
- November 30, 2026
This week we will study the limits of computation, from an algorithmic perspective. What problems can computers solve, and what problems can’t they solve? Which problems can be solved efficiently and which can’t?
So far this semester, we typically pose some problem, think of a brute force solution, and then learn about some clever way to solve the problem much faster than brute force. At this point you might think that all problems are like this. But of course there is a lot of selection bias going on: I have chosen to tell you about problems which have nice solutions! In fact, there are quite a few problems—real-world problems that people actually care about—which do not (as far as we know) have nice, efficient solutions.
Independent sets and vertex covers [00UQ]
- November 30, 2026
Let's start by examining two problems which are important in practice but turn out not to have efficient solutions (as far as we know).
The independent set problem [00V1]
- November 30, 2026
Definition Independent set [00UR]
- November 30, 2026
An independent set in an undirected graph G = (V,E) is a subset of vertices S \subseteq V such that no two vertices in S are adjacent.
Example Independent sets [00US]
- November 30, 2026
Remark For independent sets, bigger = harder [00UT]
- November 30, 2026
The empty set \varnothing always counts as an independent set in any graph. Intuitively, making small independent sets is easy, but making bigger ones is more difficult: the more vertices we add, the harder it is to avoid picking a vertex which is adjacent to an existing one. This leads to the following interesting question.
Problem IND-SET-OPT [00UU]
- November 30, 2026
Given an undirected graph G, what is the maximum possible size of an independent set in G?
It will also be convenient to reformulate this as a problem with a yes-or-no answer, called a decision problem.
Definition Decision problem [00VL]
- December 2, 2026
A decision problem is a problem which, for any input, expects a yes-or-no answer.
Problem IND-SET [00UV]
- November 30, 2026
Given an undirected graph G and a natural number k, does there exist an independent set in G of size k or greater?
Remark IND-SET vs IND-SET-OPT [00UW]
- November 30, 2026
If we had an algorithm to solve IND-SET-OPT, we could obviously use it to solve IND-SET: given G and k, we ask our IND-SET-OPT algorithm for the size of the largest independent set and then check whether it is greater than or equal to k. Conversely, and slightly less obviously, if we had an algorithm to solve IND-SET, we could use it to solve IND-SET-OPT with only an extra factor of \Theta (\lg V): just use binary search to repeatedly ask the IND-SET algorithm about different sizes until "zeroing in" on the unique maximum size.
Something similar often happens with many problems: there is an "optimization version" which returns a best answer, and there is also a "decision version" which takes an extra parameter and decides whether the best answer is better than the given parameter or not. Since decision problems are simpler, and we can usually solve the optimization problem by doing binary search with the decision problem, we sometimes restrict ourselves to considering only decision problems.
Remark Independent sets in practice [00UZ]
- November 30, 2026
It's not too hard to think of reasons why people might concretely care about this problem. For example, imagine that each edge in a graph represents a conflict. Perhaps the vertices are tasks and there is an edge between two tasks if they cannot be done at the same time (because they both require the same resource, for example). Then an independent set represents a set of tasks that can all successfully be done simultaneously, and a maximum independent set is the largest possible such set of tasks.
Solving IND-SET-OPT by brute force [00V0]
- November 30, 2026
What would be a brute force algorithm to solve IND-SET-OPT (or IND-SET)? Just list every possible subset of V—there are 2^V such subsets—test whether each one is independent (by iterating through every possible pair of vertices), and keep track of the largest. Naïvely, this takes something like \Theta (2^V V^2). We can probably reduce this to \Theta (2^V) if we are clever, and perhaps even something like \Theta (2^{V/2}) if we are extremely clever—but astonishingly, we do not know of any fundamentally better algorithms! All the algorithms we know of have some kind of exponential running time, that is, V shows up in an exponent.
The vertex cover problem [00V2]
- November 30, 2026
Definition Vertex cover [00V3]
- November 30, 2026
A vertex cover in an undirected graph G = (V,E) is a subset of vertices S \subseteq V such that every edge has at least one endpoint in S.
Remark Museum guards [00V5]
- November 30, 2026
Intuitively, think of each edge as a straight hallway; then we want to hire some guards to put at the vertices, where each guard can "see" the edges adjacent to their vertex. A vertex cover is then a set of vertices where we can place guards such that every edge is guarded. Obviously in this case, it is more difficult to make a small vertex cover.
Problem VERTEX-COVER [00VY]
- November 30, 2026
Given an undirected graph G and a natural number k, does there exist a vertex cover in G of size k or less?
Theorem Independent set \iff vertex cover [00V6]
- November 30, 2026
For any undirected graph G, S \subseteq V is an independent set if and only if \overline {S} is a vertex cover. (Here \overline {S} = V \setminus S is the set complement of S, i.e. the set of vertices in V which are not in S.)
Proof.
- November 30, 2026
Subproof. Independent set \iff vertex cover ›
- November 30, 2026
Subproof. Independent set \iff vertex cover ›
- November 30, 2026
Corollary Maximum independent set \iff minimum vertex cover [00V7]
- November 30, 2026
S is a maximum independent set in G if and only if \overline {S} is a minimum vertex cover.
Proof.
- November 30, 2026
Satisfiability [00UX]
- November 30, 2026
Suppose we are given a set X = \{x_1, \dots , x_n\} of Boolean variables.
Definition Term [00V8]
- November 30, 2026
A term is either a variable x_i, or the logical negation of a variable, which we write \overline {x_i} (the negation of x_i is also often written \neg x_i).
Example Terms [00V9]
- November 30, 2026
For example, x_1 is a term, as is \overline {x_3}.
Definition Clause [00VA]
- November 30, 2026
A clause is a disjunction of one or more terms, t_1 \lor \dots \lor t_l.
Example Clauses [00VB]
- November 30, 2026
For example, x_1 \lor \overline {x_3} \lor x_4 is a clause. (Note there’s nothing in the definition precluding repeated variables like x_1 \lor x_1 \lor x_1 \lor x_3, but such repetition does not add anything from a logical point of view, so we usually think of the variables as being distinct.)
Definition Truth assignment [00VC]
- November 30, 2026
A truth assignment is a function X \to \{\mathsf {T},\mathsf {F}\} assigning a value of true or false to each variable x_i.
Definition Clause satisfaction [00VD]
- November 30, 2026
A truth assignment satisfies a clause C if it causes C to evaluate to true (under the usual rules of Boolean logic).
Example Clause satisfaction [00VE]
- November 30, 2026
For example, \{x_1 \mapsto \mathsf {T}, x_2 \mapsto \mathsf {F}, x_3 \mapsto \mathsf {F}, x_4 \mapsto \mathsf {F} \} satisfies x_1 \lor \overline {x_3} \lor x_4, but \{x_1 \mapsto \mathsf {F}, x_2 \mapsto \mathsf {F}, x_3 \mapsto \mathsf {T}, x_4 \mapsto \mathsf {F} \} does not. Note that it is always possible to come up with a satisfying truth assignment for any clause: just pick one of the terms and make it true.
Definition Satisfiability [00VF]
- November 30, 2026
A truth assignment v : X \to \{\mathsf {T},\mathsf {F}\} satisfies a collection of clauses C_1, \dots , C_k if it satisfies all of them (that is, it satisfies C_1 \land C_2 \land \dots \land C_k). We say that v is a satisfying assignment for \{C_1, \dots , C_k\}. When a collection of clauses has some satisfying assignment, we say it is satisfiable.
Example Satisfiable and unsatisfiable clause sets [00VG]
- November 30, 2026
For example, (x_1 \lor \overline {x_2}), (\overline {x_1} \lor \overline {x_3}), (x_2 \lor \overline {x_3}) is satisfiable: just set all x_i to \mathsf {F}. (This is not the only possible satisfying assignment.)
On the other hand, as you can verify, x_1, (x_3 \lor \overline {x_1}), (\overline {x_3} \lor \overline {x_1}) is not satisfiable: there is no way to assign truth values to the x_i which will simultaneously satisfy all the clauses.
Given these definitions, we can state the following problems:
Problem SAT [00VH]
- November 30, 2026
Satisfiability (SAT): Given clauses C_1, \dots , C_k over the variables X = \{x_1, \dots , x_n\}, is the collection of clauses satisfiable?
Here is another variant of SAT which seems like it might be easier (though as we will see, it is not):
Problem 3-SAT [00VI]
- November 30, 2026
3-SAT: Given a collection of clauses C_1, \dots , C_k each containing exactly three variables, is it satisfiable?
Solving SAT by brute force [00VJ]
- November 30, 2026
A brute-force algorithm for SAT (or 3-SAT) is to just try every possible truth assignment and check if any are satisfying. But if there are n variables, then there are 2^n possible truth assignments, so this brute force algorithm takes \Omega (2^n). Once again, it turns out that we do not know any fundamentally faster algorithms, although in practice there are "SAT solvers" which are vastly more efficient on real, practical problems than one might expect, even though there still exist worst-case inputs which would make them take exponential time.
\mathcal {P} and \mathcal {NP} [00VK]
- December 2, 2026
Motivation [00VM]
- December 2, 2026
Often, problems which seem hard to solve can nonetheless be easy to verify if we are handed a (potential) solution. For example, consider the IND-SET problem. We don’t yet know how hard it is to solve, but if someone hands you a set which they claim is an independent set of size \leq k, it is easy to verify whether it has the desired size and is, in fact, an independent set—just check each pair of vertices in the set to see whether they are connected by an edge. 3-SAT is similar: if someone hands you a variable assignment, all you have to do is plug it in and evaluate the clauses to see whether they are all satisfied.
Let’s be a bit more formal. We will suppose that the input to a problem is encoded as a binary string s. Formally, the “size” of the input will now be the number of bits, n = |s|. We will also identify a decision problem D with the set of all inputs s for which the answer should be “yes”. The problem then boils down to deciding whether a given bitstring s is contained in D or not. (This is another reason why studying decision problems is particularly nice.)
Definition Solve [00VN]
- December 2, 2026
An algorithm A solves a decision problem D if for all binary strings s, A(s) = \mathsf {T} iff s \in D. (Remember that we are identifying decision problems with the set of inputs for which the answer is \mathsf {T}.)
(Really, to be completely formal, we would need to identify an “algorithm” with some concrete model of computation, typically a Turing machine; but we will leave that level of formality to a Theory of Computation course.)
The class \mathcal {P} [00VS]
- December 2, 2026
Definition Polynomial time [00VO]
- December 2, 2026
If there is a polynomial p(n) such that A(s) always terminates in at most p(|s|) steps, we say A is a polynomial-time algorithm.
Definition \mathcal {P} [00VP]
- December 2, 2026
We define \mathcal {P} as the set of decision problems D solvable in polynomial time. That is, D \in \mathcal {P} if there exists some polynomial-time algorithm A which solves D.
Remark \mathcal {P} is problems [00VR]
- December 2, 2026
Note that \mathcal {P} is a set of problems, not a set of algorithms; it is the set of all problems which can be solved by some polynomial-time algorithm. For example, it does not make sense to say that Dijkstra's Algorithm is in \mathcal {P}; but it does make sense to say that the \mathsf {SHORTEST}-\mathsf {PATH} problem is in \mathcal {P}, since it can be solved by Dijkstra's Algorithm (which, as we know, is a polynomial-time algorithm).
Remark Why \mathcal {P}? [00VQ]
- December 2, 2026
Why focus on \mathcal {P}? As mentioned previously, we typically take polynomial-time as our definition of "feasible". There is both a theoretical and a practical reason for this. The theoretical reason is that the set of polynomials is closed under many natural operations. For example, if p(n) and q(n) are polynomials, then p(n) + q(n), p(n)q(n), and even p(q(n)) are all polynomials as well. If we have two algorithms which take time p(n) and q(n) respectively, then p(n) + q(n) represents the time to run the two algorithms in sequence; p(n)q(n) represents the time to run one nested inside the other; and even p(q(n)) corresponds to a natural operation on algorithms which we will encounter shortly. So if we focus on algorithms in \mathcal {P}, we can combine them in many natural ways and still remain in \mathcal {P}.
This would be a bad reason if it were only theoretically nice but did not correspond to reality very well. However, polynomial time corresponds well to what is feasible in practice. Most real polynomial-time algorithms have relatively small exponents; the biggest power I have ever seen in an algorithm which is actually used in practice is n^6. And there are many cases where a small tweak is all that separates a problem from being solvable in something like \Theta (n^2) time to requiring \Theta (2^n) time. That is, problems don't "degrade gracefully" from feasible to infeasible; there often seems to be a sharp divide where problems suddenly jump from having a nice, efficient, polynomial-time solution to having only exponential-time solutions.
The class \mathcal {NP} [00VT]
- December 2, 2026
Motivation [00VU]
- December 2, 2026
Now let’s formally define what it means to be able to verify the solution to a decision problem. The idea is that we need some sort of extra information to verify a positive answer to a decision problem. For example, given some large graph, if someone were to claim that there was an independent set of size \geq 20, you would challenge them to prove it to you by showing you the independent set. Given an actual set of vertices, it would be easy for you to check that the set has size \geq 20 and also that no two vertices in the set have an edge between them. Conversely, if there is no independent set of that size, then no one is going to be able to fool you by giving you some weird set of vertices. The extra information required to verify a solution is called a certificate.
Definition Polynomial-time certifier [00VV]
- December 2, 2026
An algorithm B is a polynomial-time certifier for a decision problem D if:
- B is a polynomial-time algorithm taking some inputs s and t
- There is a polynomial p such that for all bitstrings s, we have s \in D if and only if there is some bitstring t (called a certificate) with |t| \leq p(|s|) and B(s,t) = \mathsf {T}.
In other words, s \in D if and only if there is a (not too big) certificate “proving” it, which can be efficiently checked. That is, if the answer for the input s is supposed to be \mathsf {T}, then there is a certificate t that proves it: the certifier algorithm B, when run on s and t, will return \mathsf {T}. Conversely, if s \notin D, there is no t that works: B will never return \mathsf {T} for a certificate t unless s really is in D.
Example Polnomial-time certifier for IND-SET [00VW]
- December 2, 2026
For example, again thinking about IND-SET, s is of course a description of a graph G and a number k; a certificate t is simply a list of vertices S; the algorithm B checks whether |S| \geq k and whether each pair of vertices in S is not connected by an edge in G. This takes something like \Theta (|S|^2) time which is clearly polynomial in the size of the graph, since |S| \leq |V|.
Definition \mathcal {NP} [00VX]
- December 2, 2026
\mathcal {NP} is defined as the set of all decision problems which have a polynomial-time certifier.
Example \mathcal {NP} problems so far [00VZ]
- December 2, 2026
For example, 3-SAT, VERTEX-COVER, and IND-SET are all in \mathcal {NP} according to our discussion above.
Remark \mathcal {NP} = nondeterminism [00W0]
- December 2, 2026
\mathcal {NP} stands for “nondeterministic polynomial time”. The idea is that if we could make nondeterministic choices (i.e. choose multiple things at once and try them in parallel), we could solve any \mathcal {NP} problem in polynomial time: just nondeterministically make all possible choices for the certificate t and check them all at the same time.
\mathcal {P} vs \mathcal {NP} [00W1]
- December 2, 2026
What is the relationship between \mathcal {P} and \mathcal {NP}? We can first observe that:
Theorem \mathcal {P} \subseteq \mathcal {NP} [00W2]
- December 2, 2026
Proof.
- December 2, 2026
Question Does \mathcal {P} = \mathcal {NP}? [00W3]
- December 2, 2026
The question of whether \mathcal {P} = \mathcal {NP} is literally worth $1 million (it is one of the seven “Millenium Prize Problems” published by the Clay Mathematics Institute). It seems too good to be true, and most believe the answer is no. But this seems extremely difficult to prove.
Remark [00W4]
- December 2, 2026
We now understand the technical definition of the famous P vs NP problem; but what is not yet obvious is why this problem is interesting. To understand that, we must first build up some machinery around the idea of reducing one problem to another.
Reducibility and \mathcal {NP}-completeness [00UY]
- November 30, 2026
Reducibility [00WC]
- December 3, 2026
Suppose we have an algorithm to solve problem B, which we can think of as a black box that takes some inputs describing a problem instance and yields an appropriate output:
We can then think of our algorithm as a “subroutine” to turn it into a solution to another problem:
- The function f translates inputs for problem A into inputs for problem B.
- The function g translates outputs for problem B into outputs for problem A.
- Note we can even allow multiple “calls” to B.
Of course, this is only useful if this really does solve problem A. That is, we need the property that if y is a solution of problem B for input f(x), then g(y) is a solution of problem A for input x. In this case we write A \leq B (“A is reducible to B”). Note we can prove such a reduction without having an actual algorithm to solve problem B: we just show that if we had an algorithm to solve B then we could also use it to solve A.
Poly-time reducibility [00WK]
- December 3, 2026
We also typically care about how long the reduction takes.
Definition Polynomial-time reducibility [00WD]
- December 3, 2026
If A \leq B and the translation functions f and g take polynomial time to compute, and the reduction makes only a polynomial number of subroutine calls to B, then we say that A is polynomial-time reducible to B, and write A \leq _P B.
Example Bipartite matching \leq _P max flow [00WE]
- December 3, 2026
As we saw earlier in the semester, finding bipartite matchings is poly-time reducible to max flow. The "translation functions" only take an amount of time which is linear (hence polynomial) in the size of the input graph.
Example IND-SET and Reducibility and \mathcal {NP}-completeness [00WF]
- December 3, 2026
As another simple example, we saw that IND-SET \leq _P VERTEX-COVER and vice versa: given a graph G = (V,E) and natural number k as input, all the translation function f has to do is replace k by |V| - k.
Example 3-SAT \leq _P SAT [00WG]
- December 3, 2026
Clearly 3-SAT \leq _P SAT: any instance of 3-SAT is in fact a valid instance of SAT as well, so the "reduction" doesn't even have to do any work.
It turns out (but is extremely nonobvious!) that the other direction is true as well: SAT \leq _P 3-SAT (we will prove this eventually). So in some sense even though the special case of 3-SAT seems like it might be “easier” than the general case of SAT, it is not.
Why 3, you ask? Because 3 is the smallest k for which k-SAT is just as hard as SAT. It turns out that 2-SAT, where all clauses have exactly two variables, is much easier, and can even be solved in linear time. (1-SAT, of course, is trivial (though not as trivial as 0-SAT).)
Lemma Poly-time reducibility preserves poly-time solvability [00WL]
- December 3, 2026
Suppose A and B are decision problems with A \leq _P B. If B is solvable in polynomial time, then so is A.
Proof.
- December 3, 2026
Suppose we have an input x to A of size n. Suppose the translation function f (which converts x into an input suitable for B) takes time p(n) to compute, for some polynomial p. Note that this means the size of f’s output is also O(p(n)), since it takes p(n) time and it has to produce the entire output in that time.
Now suppose B can be solved in time q(m), where q is a polynomial and m is the size of its input. Then the total time to solve problem A on input x, using the reduction to B, is the time to convert the input plus the time to run B on an input of size O(p(n)), that is, p(n) + q(p(n)). Since p and q are polynomials, and polynomials are closed under addition and substitution, this is a polynomial.
Remark [00WM]
- December 3, 2026
It is not too hard to extend the above lemma and proof in a couple ways:
- If A and B are not decision problems then we must also take into account the time needed to run the output conversion.
- We can also take into account the case where B is called a polynomial number of times as a subroutine—it essentially involves multiplying by another polynomial, though to do it formally one has to be a bit more careful to state that we have not just a single input conversion function but many, which are all bounded by some polynomial runtime.
Corollary [00WN]
- December 3, 2026
Suppose A \leq _P B. If A is not solvable in polynomial time, then neither is B.
Remark [00WO]
- December 3, 2026
Intuitively, if A \leq _P B then B is “at least as hard as” A (that is, with respect to solvability in polynomial time).
Lemma Properties of \leq _P [00WP]
- December 3, 2026
\leq _P is reflexive and transitive.
Proof.
- December 3, 2026
Theorem 3-SAT \leq _P IND-SET [00WQ]
- December 3, 2026
Although the two problems seem totally unrelated, it turns out that we can reduce 3-SAT to IND-SET (in fact, as we will see, we can reduce in the other direction as well)!
Proof.
- December 3, 2026
We want to exhibit a polynomial reduction from 3-SAT to IND-SET. That is, given a black box to solve IND-SET, we want to show how we could use it to solve 3-SAT, using only a polynomial amount of additional work.
Given a set of 3-SAT clauses, we want to find a satisfying assignment, which has to make each clause true. In order to make a clause true it suffices to choose exactly one term from each clause which will be set to \mathsf {T}. (Note that “setting \overline {x_i} to True” of course means setting x_i to \mathsf {F}.) However, we have to choose consistently: we can never pick both x_i and \overline {x_i}.
We start by constructing a graph G with 3k vertices arranged in k triangles, like so:
Each triangle corresponds to a clause, and each vertex corresponds to a term; in particular, label v_{ij} by the jth term from clause C_i. So, for example, given the clauses (x_1 \lor \overline {x_3} \lor x_4), (x_2 \lor x_1 \lor x_3), (\overline {x_1} \lor x_3 \lor \overline {x_4}), we would start by constructing the graph
This graph always has independent sets of size k (but no bigger): just pick exactly one node from each triangle. However, we don’t want to allow picking just any old combination of nodes. So we add more edges: in particular, add an edge between every pair of nodes labelled by x_i and \overline {x_i} for some i. So our example graph becomes:
An independent set can’t contain both endpoints of an edge. These edges therefore encode the constraint that we have to choose variables consistently: we can never choose both x_i and \overline {x_i}.
The claim is now that this graph has an independent set of size \geq k iff the original 3-SAT instance is satisfiable—and hence we can solve the original 3-SAT instance by asking our black box for whether this graph has an independent set of size \geq k. If the graph has an independent set of size \geq k, it must in fact have size exactly k and consist of a choice of one term from each clause. Just making these terms \mathsf {T} will result in a satisfying assignment (variables which do not correspond to any chosen term can be set to anything, say, \mathsf {F}); this is well-defined because we will never have both x_i and \overline {x_i} selected (because of the extra edges we added). Conversely, if there is a satisfying assignment, just choose one vertex from each triangle whose label is \mathsf {T} under the assignment (since it is a satisfying assignment, each clause must have at least one term which is \mathsf {T}). Any two vertices connected by an edge are either in the same triangle (and we only pick one vertex from each triangle) or are labelled with inverse terms (and hence can’t both be labelled \mathsf {T}), so this is an independent set of size k.
Finally, this reduction does only a polynomial amount of work: given k clauses we construct a graph with \Theta (k) vertices and O(k^2) edges.
\mathcal {NP}-hardness [00WH]
- December 3, 2026
Definition \mathcal {NP}-hard [00WI]
- December 3, 2026
A decision problem X is \mathcal {NP}-hard if for all D \in \mathcal {NP}, D \leq _P X.
Remark Intuition for \mathcal {NP}-hardness [00WJ]
- December 3, 2026
Intuitively, a problem is \mathcal {NP}-hard if it is “at least as hard as everything in \mathcal {NP}”. It seems reasonable that there might be some extremely hard problems which fit the bill—though how on earth would we go about proving it? To show that X is \mathcal {NP}-hard, we have to somehow show that every \mathcal {NP} problem can be reduced to X, which at first glance seems impossible.
Lemma Chaining \mathcal {NP}-hardness [00WR]
- December 4, 2026
If X is \mathcal {NP}-hard and X \leq _P Y then Y is \mathcal {NP}-hard.
Proof.
- December 4, 2026
So, if we can find just one \mathcal {NP}-hard problem, we can potentially use this lemma to find others.
\mathcal {NP}-completeness [00WT]
- December 4, 2026
Definition \mathcal {NP}-complete [00WS]
- December 4, 2026
A decision problem X is \mathcal {NP}-complete if both X \in \mathcal {NP} and X is \mathcal {NP}-hard.
Remark [00WU]
- December 4, 2026
It is not at all clear that any such problems exist at all! We could just as easily imagine a situation where there are just a bunch of problems in \mathcal {NP} which are “maximally hard”—that is, no other problems in \mathcal {NP} are harder—but are still not harder than everything in \mathcal {NP}. Or we could imagine that the only problems harder than everything in \mathcal {NP} are themselves so hard that they are not in \mathcal {NP}.
Proposition \mathcal {NP}-completeness and \mathcal {P} vs \mathcal {NP} [00WV]
- December 4, 2026
If a decision problem X is \mathcal {NP}-complete, then X is solvable in polynomial time if and only if \mathcal {P} = \mathcal {NP}.
Proof.
- December 4, 2026
(\Longrightarrow ) If X is solvable in polynomial time, then by a previous lemma, any Y with Y \leq _P X is also solvable in polynomial time. But if X is \mathcal {NP}-complete then by definition it is \mathcal {NP}-hard, meaning that every problem in \mathcal {NP} is reducible to X and hence solvable in polynomial time.
(\Longleftarrow ) If X is \mathcal {NP}-complete then by definition X \in \mathcal {NP}, so if \mathcal {P} = \mathcal {NP} then X \in \mathcal {P}.
Corollary [00WW]
- December 4, 2026
If you come up with a polynomial-time algorithm to solve an \mathcal {NP}-complete problem, you win $1 million.
Remark [00WX]
- December 4, 2026
Good luck. Note that this is not just theoretical; it turns out that there are a great many \mathcal {NP}-complete problems that people actually care about on a practical level. So lots of smart people have been trying hard for a long time to develop good algorithms to solve them, but no one has ever come up with any polynomial-time algorithms for any of them.
The first \mathcal {NP}-complete problem [00WY]
- December 4, 2026
Definition Boolean circuit [00WZ]
- December 4, 2026
A boolean circuit is a directed, acyclic graph G such that:
- Each indegree-0 vertex (“input”) is labelled with either \mathsf {T}, \mathsf {F}, or a distinct variable.
- All other vertices have indegree 1 or 2, and are labelled with either \neg (if indegree 1) or \lor or \land (if indegree 2).
- Only one vertex has outdegree 0, which we call the “output”.
(Note this is not really a “circuit” as we would usually conceive it, since in particular there are no loops!)
Remark [00X2]
- December 4, 2026
Given a truth assignment for the variables labelling the inputs, we think of a Boolean circuit as resulting in a \mathsf {T} / \mathsf {F} value in the obvious way: each edge corresponds to a wire which carries a single \mathsf {T} / \mathsf {F} value to the input of the next logic gate. Boolean circuits come with a natural decision problem.
Problem CIRCUIT-SAT [00X0]
- December 4, 2026
Given a boolean circuit, is there an assignment of the input variables such that the circuit outputs \mathsf {T}?
Theorem CIRCUIT-SAT is \mathcal {NP}-complete [00X1]
- December 4, 2026
Around 1971, Stephen Cook and Leonid Levin independently proved that \mathcal {NP}-complete problems exist, although their proofs were a bit different than the one presented here.
Proof.
- December 4, 2026
First, it is easy to see that CIRCUIT-SAT \in \mathcal {NP}: a certificate is a truth assignment; to verify it in polynomial time we can just run the circuit and check that it outputs \mathsf {T}.
Now we must show CIRCUIT-SAT is \mathcal {NP}-hard. Suppose X \in \mathcal {NP}, i.e. X has a polynomial-time certifier B. We must show X \leq _P CIRCUIT-SAT.
Since B is an algorithm, it can be encoded as a boolean circuit (proof: computers exist, and any boolean function can be encoded using \land , \lor , \neg ). Well, except for one problem: our boolean circuits have no loops. But we can circumvent that by simply “unrolling” any loops, by making a whole bunch of copies of a circuit that computes a single step. If the algorithm only runs for a polynomial amount of time then we need at most a polynomial number of copies to make this work. So, intuitively, we can build a polynomial-sized boolean circuit that simulates the algorithm B. Given an input s, we fix the inputs corresponding to s, and leave as variables the inputs corresponding to t. Now we ask whether the resulting circuit is satisfiable. If it is, that means there is some t such that B(s,t) = \mathsf {T}, that is, s \in X. If it is not satisfiable, then there is no such t, so s \notin X. Hence X \leq _P CIRCUIT-SAT.
Now that we know there is one \mathcal {NP}-hard problem, finding others is a lot simpler!
Theorem [00X3]
- December 4, 2026
Corollary [00X4]
- December 4, 2026
SAT, IND-SET, and Vertex cover are all \mathcal {NP}-complete.
Proof.
- December 4, 2026
Remark [00X5]
- December 4, 2026
This is amazing. Just by looking at the definitions it wasn’t at all clear whether we would be able to find a single problem which was \mathcal {NP}-complete, and now we have found five. In fact, it turns out that we currently know of hundreds of “natural” problems which are \mathcal {NP}-complete. Richard Karp got this all started with his 1979 paper proving 21 different \mathcal {NP}-hard problems.
So, the “reason” CIRCUIT-SAT is \mathcal {NP}-hard is that we can use it to model arbitrary computation, by essentially building a little computer. But think about what this transitive chain of reductions is then showing us: we can take a circuit modelling a computer and reduce it to a 3-SAT instance which models the same computer. But we can then in turn take that 3-SAT instance modelling a computer and reduce it to a graph, such that finding an independent set of a certain size in the graph models the same computation! Computation is sneaky like that; you end up finding it in places you would not expect. Who would have guessed that finding independent sets in a graph turns out to be equivalent to doing arbitrary computation? But in some sense \mathcal {NP}-complete problems are like this, and this gives us some intuition as to why they are so hard to analyze: because you can smuggle arbitrary computation into them!
Super Mario Bros is \mathcal {NP}-hard [00X6]
- December 4, 2026
See this 2012 paper by Aloupis et al. showing that Super Mario Bros (and a bunch of other classic video games) are \mathcal {NP}-hard, in the sense that it is hard to decide whether a given level can be beaten or not. The proof is by reduction from 3-SAT.