OBDDs: Compile once, answer forever
In 1986, Randal Bryant at Carnegie Mellon published Graph-Based Algorithms for Boolean Function Manipulation , which spent years as one of the most-cited papers in all of computer science — an odd distinction for a paper about a data structure for truth tables. The reason for the citations arrived in 1990, when a graduate student named Ken McMillan used Bryant’s structure to verify a cache-coherence protocol by (in effect) examining all of its reachable states. The paper announcing the method put the headline number in its title: Symbolic Model Checking: 10²⁰ States and Beyond . A hundred quintillion states, checked, on 1990 hardware. Nobody enumerated anything, obviously. The states were represented (all of them at once) as a Boolean function, and the function was stored in the shape this chapter is about.
Chapter 4’s solvers answer one question per run: satisfiable or not, goodbye. This chapter is the other grand strategy for living with an NP-complete problem, and it trades in the opposite direction:
- The structure: the ordered, reduced binary decision diagram (OBDD) — a compressed truth table with one property that carries the whole chapter, canonicity.
- The payoff: once a formula is compiled, the questions Chapter 4’s CDCL engines would charge exponentially for (equivalence, counting, quantification) cost pennies. This is where the 10²⁰ states come from.
- The price: compilation can explode, the explosion depends savagely on variable ordering — and for one famous function we can prove no ordering helps. That proof is this book’s first unconditional exponential lower bound, and the template for everything in Part III.
The structure: a truth table, deduplicated
A truth table answers every possible question about a Boolean function, which is exactly why it’s useless: rows. But drawn as a decision tree (ask , branch, ask , branch…) the table reveals redundancy: entire subtrees repeat, and some questions don’t matter at all. An OBDD is what remains after squeezing out both, under two disciplines: fix one global variable order (every path asks the variables in the same sequence), then reduce — merge any duplicated subgraphs, and delete any node whose two branches lead to the same place. Watch it happen to the three-input majority function:
Eight rows become four decision nodes. The compression is nice; the theorem is better. For a fixed variable order, the reduced diagram is canonical: a function has exactly one OBDD, bit-for-bit, no matter what formula, circuit, or code it came from, no matter the construction path. Build the diagram for and for and you get — not equivalent structures, but the same pointer in a properly hash-consed implementation (hash-consing: a lookup table that keeps one shared copy of every distinct subgraph, so structurally equal things are literally the same object in memory).
Against the backdrop of Part I, that is strange. “Are these two formulas equivalent?” is coNP-complete — it contains UNSAT ( unsatisfiable iff ), the very problem Chapter 3 said has no known short certificates. Canonicity converts it into pointer comparison. The exponential moved: it now lives in the compilation step.
The payoff: the impossible questions become cheap
Everything below assumes the formula is already an OBDD of manageable size — nodes in the diagram, not variables. (How it gets there: the apply algorithm combines two OBDDs and with any Boolean operator in time by walking the two DAGs (directed acyclic graphs: the diagrams’ true shape) in lockstep — so you compile a circuit gate by gate, reducing as you go, never detouring through a truth table.)
- Satisfiability: is the diagram the single node
0? Constant time. Any path to1spells a satisfying assignment — Chapter 2’s certificate, read off the pointer walk. - Equivalence: pointer comparison; that’s canonicity. This is why BDDs conquered hardware: “is the optimized adder equivalent to the spec adder” (coNP-complete in general) became the daily, trivially-answered question of 1990s chip design.
- Counting: how many satisfying assignments? One bottom-up pass — each node’s count is (count below the false-branch) + (count below the true-branch), doubled once for every variable an edge skips (reduction deleted the don’t-care tests, and a skipped variable can go either way, so an edge that skips variables multiplies its count by ; the terminals seed the pass with
1counting 1 and0counting 0). Linear in the diagram. We compiled Chapter 2’s dinner-party formula under order : a 7-node diagram, and the pass returns 3, the guest lists , mechanically recovered. This problem, #SAT, is believed harder than NP (it answers “how many,” not “whether”), and the diagram hands it over in linear time. - Quantification and substitution: compute "" — the function that’s true when some value of makes true — that is, — or restrict , each as a small diagram operation. Chain quantification with apply and you can ask: starting from these states, which states are reachable in one step? In two? Iterate to a fixed point and you’ve computed the reachable set of a state machine without ever listing a state — each iteration is just diagram surgery. That loop is McMillan’s symbolic model checking, and the 10²⁰ states were a 10²⁰-row truth table that happened to compress into a small diagram.
Without compiling first, can you at least approximate the count — or attack SAT by counting the non-solutions?
The answers are “it depends which side you count,” and the asymmetry is a razor edge all its own: two numbers summing to , one approximable, one not. Approximating itself, even within a factor of a million, is as hard as SAT: any multiplicative estimate distinguishes zero solutions from some, which is the decision problem. But the number of non-solutions — , the assignments the formula kills — is, by De Morgan, the solution count of a DNF (an OR of ANDs), and DNF counting has a fully polynomial randomized approximation scheme (Karp–Luby–Madras ). Two numbers summing to : one can’t be approximated unless RP (randomized polynomial time) = NP, the other you can estimate to 1% in polynomial time, today. And neither touches SAT — deciding satisfiability through the easy side means telling non-solutions apart from , a relative gap of , exponentially finer than any approximation scheme reaches. The coarse magnitude is free; the hardness lives entirely in the last few bits. (Chapter 11 has the matching theorem for the other pole: exact one-bit shadows of the count — its parity, even mere comparisons — stay maximally hard.)
The same conservation law swallows the natural attacks. Count non-solutions exactly? That’s restated. Add clauses and test whether the kill-count grew — say, add both and , making everything invalid, so the growth equals exactly? A correct identity, and the test is “is satisfiable” wearing a new coat; chase any such difference scheme down and it telescopes into branching on variables, which is Chapter 4’s DPLL rediscovered. The best exact counters known are precisely such branchers, sharpened: about for #3SAT — a real improvement on brute force’s , and still exponential. Every reformulation conserves the hard quantity; only compilation (this chapter) or an easy-side approximation changes what you actually pay.
The right frame for all of this (one that generalizes well past BDDs) is knowledge compilation: pay a possibly-painful cost once to put knowledge into a shape whose queries are then guaranteed cheap, the same trade as building a database index or sorting before binary search. CDCL and OBDDs are the two poles of the trade: the solver pays nothing up front and gambles per query; the diagram pays everything up front and then answers like a lookup table. Which pole wins depends entirely on whether the compiled artifact stays small. That’s where the bill arrives.
The price: ordering is destiny
Canonicity was quietly conditional: canonical given the variable order. The order is a free choice. Here is one function under two orders — compiled live, in your browser, by real Shannon expansion — the recursive ask-a-variable-and-split move that built the figure above: is “if then else ,” where means with pinned to 0 — and reduction:
The function is three independent pairs — of them in general: , drawn for . Interleave the pairs in the order and each pair resolves before the next begins: 6 nodes, growing as . Put all the ‘s before all the ‘s and the top half of the diagram must remember the complete triple — every distinct combination needs its own node, because any of them can still matter once the ‘s arrive: 14 nodes, growing as . At pairs, the same function is either 128 nodes or — about 700 exabytes at twenty bytes a node (a variable index plus two child pointers). Same function. The diagram’s width at each level is exactly how much the function forces you to remember about the variables read so far.
So everything rides on finding a good order. Can we? Heuristics (and dynamic reordering mid-computation) work well in practice; optimally, no: improving a given order is NP-complete (Bollig–Wegener). There’s a recursion here — the data structure for taming NP-complete problems has an NP-complete installation step — but read it as the usual Part II arrangement: heuristics standing in for guarantees.
The deeper question is whether a good order exists at all, and here sits this book’s first exponential lower bound against a model people actually use, proven unconditionally, with no conjectures leaning on it. Some functions are exponential under every order. Bryant proved it in 1991 about the one function engineers most wanted to compile: the middle output bit of -bit integer multiplication requires at least nodes under every variable ordering. No cleverness escapes it. (A cheap canonical form for multiplication would come uncomfortably close to making factoring easy — restrict the compiled multiplier’s output bits to a target number and read satisfying inputs, that is, factors, off the diagram: Chapter 1’s multiply-easy-factor-hard asymmetry, defending itself.)
How do you prove a lower bound against every ordering — isn’t that infinitely many cases?
With one counting argument that covers them all — the template for all of Part III. Fix any order. Cut the diagram at level : the variables read so far are a set , the rest . The diagram’s width at the cut equals the number of distinct subfunctions the inputs in can induce on — in communication terms, how many distinguishable messages about the function forces across the cut. (That framing has a name, communication complexity, and it is the field behind most of the unconditional lower bounds humanity owns; Chapter 10 gives it a chapter of its own, with this very cut as the running example.) To lower-bound the width, exhibit a fooling set: many settings of no two of which behave identically on all of . Each needs its own node. Bryant’s proof shows that for the middle bit of multiplication, every balanced cut (wherever an adversarial ordering puts it) is forced to carry exponentially many distinguishable messages, essentially because multiplication’s carry chains make distant input bits interact (the same convolution structure that makes it a good hash of its inputs). One argument, quantified over all orders at once. ∎
The general shape — find a resource the restricted model must spend (here: width across a cut), then show the target function demands exponentially much of it — is exactly how Part III attacks circuits. And the model here isn’t a toy: OBDDs are a special case of branching programs, and strong enough lower bounds on general branching programs would imply major separations. The wall between “we can prove it for OBDDs” and “we can’t for circuits” is the wall this book is about.
CDCL dodges the worst case by mining the structure of engineered instances. OBDDs dodge it when the function’s information flow is narrow. And both have provable walls: formula families that Chapter 8 will prove force exponential work from any clause-learning engine, and the multiplier for OBDDs. Both escape acts exploit the same loophole: real instances aren’t adversarial. Which raises a question neither chapter answered: what does a genuinely structureless instance even look like — and are such instances actually hard, or is hardness rare everywhere outside textbook constructions? There’s a clean way to make the question empirical: generate SAT instances uniformly at random, with one dial controlling how constrained they are, and watch what happens as you turn the dial. What happens is one of the strangest experimental discoveries in computer science — a phase transition as sharp as ice melting, at a dial setting physicists have since pinned to four decimal places, where all the hard instances in the random universe congregate. That’s Chapter 6.
Further reading
- Graph-Based Algorithms for Boolean Function Manipulation (Bryant, 1986) — the original; the apply algorithm’s lockstep walk is drawn in full.
- Symbolic Model Checking: 10²⁰ States and Beyond (Burch, Clarke, McMillan, Dill & Hwang, 1990) — the paper that turned a data structure into an industry.
- On the Complexity of VLSI Implementations and Graph Representations of Boolean Functions (Bryant, 1991) — the multiplier lower bound; section 4 is the fooling-set argument.
- A Knowledge Compilation Map (Darwiche & Marquis, 2002) — the full menu of compiled forms and exactly which queries each makes cheap; the systematic version of this chapter’s trade-off.
- The Art of Computer Programming, Vol. 4A, §7.1.4 (Knuth) — BDDs and ZDDs with Knuth-grade care, including the ordering heuristics.