SAT and 3-SAT
Suppose you are scheduling exams, routing chips, or configuring a software package with thousands of interacting constraints. Each constraint can often be written as a logical requirement. For example: "if course A is scheduled Monday, then course B cannot be." The whole system succeeds only if every requirement holds simultaneously. This is the Boolean satisfiability problem, universally abbreviated SAT. Given a formula built from Boolean variables, AND, OR, and NOT, does there exist an assignment of TRUE/FALSE to the variables? That assignment must make the whole formula TRUE. SAT is not just one more puzzle. It is the problem that anchors the entire theory of NP-Completeness. Every problem in The Class NP can be translated into a SAT instance. This fact was proved by the Cook-Levin theorem — the historical starting point of NP-completeness theory. A restricted version, 3-SAT, has every clause with exactly three literals. It is equally hard. It is the workhorse used to prove hardness of dozens of other problems. These range from graph coloring to scheduling to bin packing. The big picture: SAT sits at the boundary between "efficiently solvable" and "believed intractable." No polynomial-time algorithm is known for SAT. Finding one (or proving none exists) would resolve the P vs. NP question. Yet SAT is trivially verifiable. Given a candidate assignment, checking it satisfies the formula takes only linear time. This asymmetry between "hard to find, easy to check" is the defining signature of NP. SAT is its most fundamental representative. This article defines CNF and 3-CNF precisely. It explains why SAT and 3-SAT are natural NP problems. It walks through the verification algorithm and the standard clause-based reasoning used in reductions. It traces a worked example by hand. It previews how SAT's hardness transfers to other problems via reductions — the technique formalized in the Cook-Levin theorem.
- SAT asks whether a Boolean formula has a satisfying TRUE/FALSE assignment to its variables.
- CNF (conjunctive normal form) is an AND-of-ORs; 3-CNF restricts every OR-clause to exactly three literals.
- SAT and 3-SAT are both in NP: a proposed assignment can be checked in polynomial time.
- The Cook-Levin theorem shows SAT is NP-complete — every NP problem reduces to it.
- 3-SAT is also NP-complete, obtained by a polynomial reduction from general SAT, and is the standard reduction source.
- 2-SAT, in contrast, is solvable in polynomial time, showing the clause-width boundary is sharp.
SAT and 3-SAT ask for a satisfying assignment to a Boolean formula, are efficiently verifiable, and are NP-complete, making them the universal starting point for proving other problems intractable.
The idea
A Boolean formula is built from variables , each taking value TRUE (1) or FALSE (0), combined with the connectives AND (), OR (), and NOT (). A literal is a variable or its negation, e.g. or . The satisfiability problem (SAT) asks: given a formula , does there exist an assignment of truth values to its variables under which evaluates to TRUE? If such an assignment exists, is satisfiable; otherwise it is unsatisfiable. Most treatments of SAT restrict attention to conjunctive normal form (CNF): a formula that is an AND of clauses, where each clause is an OR of literals. For example,
is in CNF with three clauses. CNF is a universal normal form — any Boolean formula can be converted to an equivalent-satisfiability CNF formula in polynomial time (via the Tseitin transformation, introducing auxiliary variables), so restricting SAT to CNF inputs loses no generality for complexity purposes. 3-CNF further restricts every clause to have exactly three literals (over possibly repeated or negated variables); 3-SAT is the satisfiability problem restricted to 3-CNF formulas. Formally, as decision problems:
Both languages live in NP: a satisfying assignment serves as a polynomially-sized certificate, and checking that an assignment satisfies a formula is a simple linear scan. The deep result — the Cook-Levin Theorem — is that SAT is not merely in NP but NP-complete: every language decidable by a nondeterministic polynomial-time Turing machine reduces to SAT in polynomial time. This makes SAT a "universal" problem for NP: solving SAT in polynomial time would imply P = NP. A further reduction shows 3-SAT is NP-complete too, which is why 3-SAT — not general SAT — is the typical starting point when proving new problems NP-complete (as later used for Classic NP-Complete Problems: Clique and Vertex Cover).
How it works
There are two algorithmic stories to tell for SAT: the polynomial-time verifier, which places SAT in NP, and the exponential-time search/decision procedures actually used to solve it (since no polynomial algorithm is known). Both are worth understanding precisely.
Verification. Given a formula in CNF with clauses over variables, and a candidate assignment , checking requires evaluating each clause (a clause is TRUE if at least one of its literals is TRUE under ) and taking the AND over all clauses. ``` Verify-SAT(φ, a):
# φ is a CNF formula: list of clauses; each clause is a list of literals
# a is an assignment: array indexed by variable, value in {0,1} for each clause C in φ: clauseSatisfied ← false for each literal ℓ in C: if ℓ = x_i and a[i] = 1: clauseSatisfied ← true break if ℓ = ¬x_i and a[i] = 0: clauseSatisfied ← true break if not clauseSatisfied: return false # this clause is false ⇒ φ is false return true # every clause satisfied ⇒ φ is satisfied ``` This runs in time proportional to the total number of literal occurrences, which is for clause length (constant for 3-SAT), hence polynomial — this is exactly what places SAT and 3-SAT in NP.
Search (brute force, and the standard reduction argument for 3-SAT from SAT). No known algorithm solves SAT faster than roughly in the worst case (modern SAT solvers do vastly better in practice via heuristics, but no worst-case polynomial bound is known or believed to exist). ``` Brute-Force-SAT(φ):
# φ is a CNF formula over variables x_1,...,x_n for each of the 2^n assignments a to x_1,...,x_n: if Verify-SAT(φ, a): return "satisfiable", a return "unsatisfiable" ```
Reducing SAT to 3-SAT. To show 3-SAT is NP-complete via SAT (rather than directly via the Cook-Levin construction), one gives a polynomial-time transformation converting any CNF clause into an equisatisfiable conjunction of 3-literal clauses:
- A clause with 1 literal : introduce two fresh variables and replace it with
.
- A clause with 2 literals : introduce fresh , replace with .
- A clause with exactly 3 literals: keep as is.
- A clause with literals : introduce fresh variables and chain them:
``` CNF-to-3CNF(φ): ψ ← empty conjunction for each clause C in φ: k ← number of literals in C if k == 3: append C to ψ else if k == 1: introduce fresh p, q append the four 3-literal clauses expanding (ℓ1) as above else if k == 2: introduce fresh p append the two 3-literal clauses expanding (ℓ1 ∨ ℓ2) else: # k > 3 introduce fresh z_1,...,z_{k-3} append the chain of (k-2) 3-literal clauses linking z_1..z_{k-3} return ψ ``` Each new clause introduces at most a constant number of fresh variables and clauses per original clause, so and the whole transformation runs in polynomial (indeed linear) time. The key correctness claim — the chain clause is satisfiable exactly when the original long clause is — is verified below.
Complexity & correctness
Membership in NP. For both SAT and 3-SAT, a satisfying assignment is a certificate of size bits. `Verify-SAT` checks it in time where is the maximum clause length (a fixed constant, 3, for 3-SAT; bounded by formula length in general). Since verification is polynomial in the input size, both problems are in NP by definition.
NP-hardness (sketch, formalized by Cook-Levin). The Cook-Levin theorem shows that for any language , decided by a nondeterministic Turing machine running in time for polynomial , one can build — in time polynomial in — a CNF formula (for input ) such that
The construction encodes the entire computation history (a tableau: one row per time step, one cell per tape position) as Boolean variables, with clauses enforcing (1) each cell holds exactly one symbol, (2) the machine starts in the correct initial configuration, (3) each configuration follows validly from the previous one according to 's transition function, and (4) some row reaches an accepting state. Because runs in time , the tableau has cells (each of the steps can move the head by at most 1, so the tape used is ), giving polynomially many variables and clauses — the reduction is polynomial-time. This article treats the theorem as a black box; the Cook-Levin Theorem entry gives the full tableau construction.
Correctness of the SAT-to-3SAT reduction. We must verify that `CNF-to-3CNF` preserves satisfiability. The 1-literal and 2-literal clause expansions are easily checked by truth table: e.g. for , the four-clause expansion is satisfiable under any assignment of precisely when is TRUE (if is FALSE, the four clauses collectively demand all four combinations of be excluded, an unsatisfiable set; if is TRUE every clause is automatically satisfied regardless of ). For the long-clause chain, the key invariant is: > Claim. is satisfiable under assignment to the original variables iff the chain of 3-literal clauses (with fresh ) is satisfiable by extending with some assignment to the . Proof. () Suppose some is TRUE under . Set for all and for all (informally: " true" means "satisfied by one of "). Each chain clause then contains either a true literal or a true/false pairing of consecutive 's that satisfies it — a direct case check confirms every clause in the chain holds. () Conversely, suppose no is TRUE. Then the first clause forces . Each subsequent clause , with false and true, forces by resolution. This propagates until the last clause , which with and false is FALSE — contradiction. Hence if no original literal is true, the chain is unsatisfiable. Since satisfiability is preserved in both directions and the transformation size is linear, 3-SAT is NP-hard; combined with membership in NP, 3-SAT is NP-complete.
Complexity summary.
| Aspect | SAT | 3-SAT |
|---|---|---|
| Verification time | ||
| Best known worst-case solving time | (no known poly algorithm) | -type bounds via specialized algorithms, still exponential |
| Class | NP-complete | NP-complete |
| Special restricted case | Horn-SAT: poly-time (unit propagation) | 2-SAT: poly-time (implication graph, SCCs) |
The honest tradeoff: while worst-case SAT solving is exponential, modern conflict-driven clause learning (CDCL) solvers routinely solve industrial instances with millions of variables in seconds — because real instances have exploitable structure absent in adversarial worst-case formulas. Theoretical hardness (worst-case, assuming P ≠ NP) and practical solvability (average-case, structured instances) are not contradictions; they describe different regimes.
Worked example
Consider the CNF formula over variables :
This has one 2-literal clause, so it is not already 3-CNF. Let's first solve it directly by brute force, then show the 3-CNF conversion of the offending clause.
Brute-force search over assignments:
| 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 |
| 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 |
| 0 | 1 | 0 | 0 | 1 | 1 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 |
| 1 | 1 | 0 | 0 | 1 | 1 | 1 | 0 |
| 1 | 1 | 1 | 1 | 1 | 0 | 1 | 0 |
Only the assignment satisfies all four clauses, so is satisfiable, and `Brute-Force-SAT` returns this assignment after checking (in the worst case) all 8 rows.
Converting to 3-CNF. It has 2 literals, so introduce a fresh variable and replace with:
Check the invariant on our satisfying assignment: makes , so both new clauses are TRUE regardless of — consistent with being TRUE under this assignment for any value of . If instead (making original false), then , so both clauses reduce to and — together these force , an unsatisfiable pair, exactly mirroring that cannot be satisfied. The transformation is confirmed correct on this instance.
Common pitfalls & traps
| Pitfall | Why it happens | Fix |
|---|---|---|
| Confusing "satisfiable" with "valid" (true under all assignments) | Natural-language ambiguity around "true formula" | SAT asks for some satisfying assignment; validity/tautology is a different (coNP) question |
| Assuming 2-SAT is also NP-complete | Pattern-matching "clauses ⇒ hard" without checking clause width | 2-SAT is solvable in polynomial time via strongly connected components of the implication graph — width 3 is the actual hardness threshold |
| Treating the CNF→3-CNF reduction as changing the meaning of the formula | The new formula has extra variables and is not logically equivalent | It is only equisatisfiable — satisfiable iff the original is — which is all a reduction needs to preserve |
| Forgetting the fresh variables must be genuinely new | Reusing an existing variable name silently corrupts the reduction | Always introduce variables not appearing anywhere else in the formula |
| Assuming brute force is "the" SAT algorithm in practice | Textbook presentation emphasizes worst-case exponential search | Real solvers (DPLL, CDCL) exploit unit propagation, clause learning, and heuristics to prune enormously in practice |
| Believing NP-completeness of SAT proves no fast algorithm can ever exist | Misreading "NP-complete" as "proven intractable" | It is only known that a polynomial algorithm would imply P = NP; this remains an open conjecture, not a theorem |
Pioneers & history
Origins · 1 minStephen A. Cook and how this was discovered
Stephen Cook, working at the University of Toronto, proved in 1971 that the Boolean satisfiability problem is NP-complete — the theorem now called the Cook-Levin theorem after Cook and, independently, Leonid Levin in the Soviet Union. This single result gave complexity theory its first "universal" hard problem and its first systematic technique — polynomial-time reduction — for showing that other problems are at least as hard as SAT. Cook received the Turing Award in 1982 largely for this contribution.
Where this matters
SAT solvers are deployed as general-purpose combinatorial engines across engineering. Hardware verification teams at chip manufacturers use SAT solvers to formally check that circuit designs match specifications, encoding equivalence checking as a satisfiability query. Software verification and bug-finding tools (symbolic execution engines, bounded model checkers) translate program paths into SAT or SMT (SAT-modulo-theories) instances to detect buffer overflows and assertion violations. AI planning and scheduling systems encode "does a valid plan of length exist" as SAT and call off-the-shelf solvers rather than write bespoke search code. Package managers (resolving mutually compatible software versions) and cryptanalysis (encoding cipher-breaking as SAT) are further practical uses. Theoretically, SAT and 3-SAT are the seed of essentially all of NP-completeness theory: the Cook-Levin Theorem establishes SAT's hardness from first principles, and 3-SAT is the standard reduction source used to establish hardness for graph problems like those in Classic NP-Complete Problems: Clique and Vertex Cover, as well as for scheduling, packing, and countless other combinatorial problems throughout NP-Completeness theory.
Ask the tutor: How exactly does the Cook-Levin tableau construction encode a Turing machine's transition function as CNF clauses?
Is SAT the same problem as 3-SAT?
Not exactly, but they are equivalent in complexity-theoretic power. SAT allows clauses of any length; 3-SAT restricts every clause to exactly 3 literals. Every 3-SAT instance is a SAT instance, so 3-SAT is no harder than SAT. The nontrivial direction is that general SAT reduces to 3-SAT in polynomial time via the clause-splitting transformation using fresh auxiliary variables. Because both directions hold, the two problems are polynomial-time equivalent: both are NP-complete, and a fast algorithm for one gives a fast algorithm for the other. 3-SAT is preferred in reductions because its uniform clause structure is easier to manipulate than variable-length clauses.
Why does 2-SAT become easy while 3-SAT stays hard?
2-SAT clauses can be rewritten as implications: is equivalent to and . Building a directed implication graph over all literals and their negations, one can show a 2-SAT formula is unsatisfiable exactly when some variable and its negation lie in the same strongly connected component. Computing SCCs takes linear time, giving a linear-time 2-SAT algorithm. This trick fundamentally relies on clauses having only two literals, so each clause yields exactly two binary implications; with three literals, no such linear encoding as pairwise implications exists, and the problem's structure becomes genuinely combinatorial.
Does NP-completeness of SAT mean it can never be solved efficiently?
No — it means finding a polynomial-time algorithm for SAT would prove P = NP, a famous open problem. NP-completeness is a relative hardness statement: SAT is at least as hard as every other problem in NP, under the standard complexity-theoretic assumption that P ≠ NP. It remains logically possible, though widely disbelieved, that P = NP and a polynomial algorithm exists. In practice, modern SAT solvers handle huge structured industrial instances quickly, showing that worst-case hardness and typical-case tractability are compatible; the theoretical guarantee is only about the hardest possible inputs.
What is the difference between a formula being satisfiable and being a tautology?
A formula is satisfiable if at least one assignment makes it TRUE; it is a tautology (or valid) if every assignment makes it TRUE. These are dual notions connected by negation: is a tautology iff is unsatisfiable. The complement of SAT (deciding unsatisfiability, or equivalently deciding validity) is the canonical coNP-complete problem, believed distinct from NP unless NP = coNP. SAT asks for existential quantification over assignments ("does there exist"), while tautology-checking asks for universal quantification ("does it hold for all") — this quantifier difference is exactly what separates NP-style and coNP-style problems.
Why is CNF the standard form used for SAT rather than arbitrary Boolean formulas?
Any Boolean formula can be transformed into an equisatisfiable CNF formula in polynomial time using the Tseitin transformation, which introduces one auxiliary variable per subformula to name its truth value and adds clauses enforcing consistency with the corresponding gate (AND, OR, NOT). The resulting CNF formula grows only linearly in the size of the original circuit, unlike naive distribution of ANDs over ORs, which can blow up exponentially. Because CNF is a universal, size-efficient target form, and its clause structure is convenient for algorithms (unit propagation, resolution, SCC methods for 2-SAT), it became the standard representation for both the theory and practical solvers.
How does the tableau construction in the Cook-Levin theorem actually build the CNF formula?
It represents an entire run of a nondeterministic Turing machine as a two-dimensional grid: rows indexed by time steps (0 to the polynomial running-time bound), columns indexed by tape positions. A Boolean variable records which symbol and machine state occupy each cell at each time. Clauses enforce four properties: each cell has exactly one symbol, the first row matches the initial configuration, each row transitions validly to the next according to the machine's transition function (checked via small local windows of cells), and some cell in some row shows an accepting state. Because the machine runs in polynomial time, the grid has polynomially many cells, giving a polynomial-size CNF formula whose satisfiability exactly captures whether the machine accepts.