Thinking Machines
the symbolic era
How far can a machine get by searching and by following rules someone wrote down?
In 1958 Simon and Newell forecast a computer chess champion within ten years; Deep Blue beat Kasparov in May 1997. The part walks through what was built in between. Turing's machine fixes what can be computed, and the halting problem what cannot. Search comes first: the 8-puzzle's 181,440 states mapped by breadth-first search, Dijkstra's wavefront, and A*, whose heuristic turns the circle of expanded cells into an ellipse and stays optimal as long as it never overestimates. Hill climbing and simulated annealing give up the guarantee for reach; minimax and alpha-beta play games, and Samuel's checkers program learns its own scoring. Logic follows: resolution, DPLL and CDCL, and the random 3-SAT transition near 4.27 clauses per variable, then constraints, STRIPS planning and expert systems. The part turns with ELIZA and the two AI winters: hand-written rules could not cover the long tail of perception and language. It ends with what survives inside AlphaZero, SAT and SMT solvers, and proof assistants.
What you need. Some programming (loops, recursion, a queue). Nothing from Part 1 is needed.
- Mathematics and history
- Turing, Dartmouth, search and A*, games and alpha–beta, logic and SAT, planning, expert systems, the AI winters
- Models, data
- Samuel's checkers, Deep Blue, ELIZA
What you will be able to do
Undergraduate
- Trace breadth-first search, uniform-cost search and A* on a small graph, and say which of them return a shortest path.
- Run minimax and alpha-beta by hand on a small game tree and mark the branches that are pruned.
- Explain the ELIZA effect and what caused each of the two AI winters.
Master's
- Prove that A* with an admissible heuristic returns an optimal path, and that a consistent heuristic makes f non-decreasing along every path.
- Derive alpha-beta's best case, and derive the Boltzmann distribution from the Metropolis rule by detailed balance.
- Refute a set of clauses by resolution, and run DPLL with unit propagation on a small formula.
Research
- Prove the halting problem undecidable by diagonalization.
- State what is proved and what is only predicted about the random 3-SAT threshold, and explain how conflict-driven clause learning differs from chronological backtracking.
Engineering
- Choose between exact search, weighted A* and local search for a problem from its size and from how much a suboptimal answer costs.
- Encode a small verification question (two circuits are equivalent) as a satisfiability problem and read the solver's answer.
Contents
Each chapter has a home level. Choose a track to see what to read and watch: Undergraduate 25 min · Master's 51 min · Research 55 min · Engineering 32 min.
- 0Forty years to checkmateUndergraduate2 min
- 1Can machines think?Undergraduate4 min
- 2SearchUndergraduate3 min
- 3A*Undergraduate4 min
- 4Where heuristics come fromMaster's4 min
- 5Climbing and coolingMaster's4 min
- 6Games and alpha-betaUndergraduate4 min
- 7Machines that learned to playMaster's4 min
- 8Logic and resolutionMaster's3 min
- 9SatisfiabilityResearch3 min
- 10Constraints and plansMaster's4 min
- 11Knowledge is powerEngineering4 min
- 12ELIZAUndergraduate2 min
- 13The wintersUndergraduate4 min
- 14What survivesEngineering4 min
- Recap, problems, and where this comes backAll tracks2 min
Also on this page: Lecture · Key results · Try it · Lab · Problems · Notes and sources · 中文 · Build the film.
Lecture
The text of each chapter is the film's narration, as it is spoken, so you can read along or revise without the film. The pictures are in the film. A dashed box stands for a number the film computes when it is rendered (hover over it to see what is computed); the README's figures for each chapter, where it lists them, follow the chapter's text.
Forty years to checkmateUndergraduate2 min
In 1958 Herbert Simon and Allen Newell predicted that within ten years a digital computer would be the world's chess champion, unless the rules barred it from competition. It took thirty-nine. In May 1997, in New York, IBM's Deep Blue beat the world champion, Garry Kasparov, three and a half games to two and a half.
Between those dates lies the first age of artificial intelligence, where this course's history begins. In 1950 Alan Turing asked whether machines could think. In 1956 a workshop at Dartmouth named the field. Programs learned checkers, held conversations, searched maps and planned a robot's moves. Then the promises outran the results, and the money dried up: a first winter. A boom in expert systems, and a second, harder winter when it collapsed. And at the end, a chess machine the founders would have recognized.
The bet of that age was that intelligence could be written down: as search through possibilities, guided by rules of thumb; as moves in a game; as logic; as knowledge typed in by experts. The bet was only half lost. Search runs inside AlphaZero, logic inside the tools that check computer chips, a proof checker grades DeepMind's AlphaProof, and today's agents make plans. And every algorithm in this part runs here, on this computer, so we can watch it work.
This is Part 2 of AI, Built. In this part: what machines can and cannot compute, and Turing's test; search, from breadth-first to A star, and where heuristics come from; local search and simulated annealing; games, from minimax and alpha-beta to Samuel's checkers and Deep Blue; logic, satisfiability and its phase transition, constraints and planning; and knowledge: expert systems, ELIZA, the two winters, and what survived them.
1Can machines think?Undergraduate4 min
Before anyone could ask whether machines think, someone had to say what a machine is. Alan Turing did, in 1936. A tape of cells holding symbols, and a head that reads one cell; and a finite table of rules: in this state, reading this symbol, write, move left or right, and switch state. This table adds one to a binary number: watch it carry. Turing argued that such a machine can compute anything a person can compute by rule, and that one universal machine, reading another's table from its own tape, can imitate them all: the idea of the stored-program computer.
Turing also showed what no machine can do. Suppose a program H could take any program P and input x, and always answer: does P eventually stop on x? Build a contrarian, D: given a program, D asks H whether it stops when fed its own text, and does the opposite. Now run D on its own text. It stops exactly when H says it doesn't: exactly when it doesn't stop. So H cannot exist: no program can decide, in general, whether programs halt. Alonzo Church reached the same limit that year, by another route.
The limit appears even in tiny machines. Fix two tape symbols and a number of working states, with a separate halt state. Start on an all-zero tape: how long can such a machine run and still halt? The longest runner is called the busy beaver, Tibor Radó's name, from 1962. The four-state champion, run here row by row, halts after steps. The five-state champion runs steps; we replayed them in seconds. Proving that no five-state machine runs longer took until 2024, and a proof checked by computer. For six states, nobody knows.
In 1950 Turing turned to thinking itself, and proposed a game instead of a definition. An interrogator exchanges typed messages with two hidden players, a person and a machine, and must say which is which. He forecast that by about 2000, an average interrogator would be right no more than seventy percent of the time after five minutes. In 2025 Cameron Jones and Benjamin Bergen ran the test: GPT-4.5, playing a persona, was judged human seventy-three percent of the time, more often than the real people. ELIZA, from 1966, managed twenty-three percent.
Six years later, in the summer of 1956, John McCarthy, Marvin Minsky, Nathaniel Rochester and Claude Shannon gathered researchers at Dartmouth College, on the conjecture that every aspect of learning or any other feature of intelligence can in principle be so precisely described that a machine can be made to simulate it. McCarthy's proposal named the field: artificial intelligence. Allen Newell, Cliff Shaw and Herbert Simon brought a working program, the Logic Theorist. It proved thirty-eight of the first fifty-two theorems in a chapter of Principia Mathematica. It worked backward from each theorem to subgoals, choosing by rules of thumb: a search through a tree of symbols. In 1976 Newell and Simon stated the era's creed: a physical symbol system has the necessary and sufficient means for general intelligent action.
2SearchUndergraduate3 min
Start, apply moves, look for a goal: that pattern is behind everything in this part. Take the eight-puzzle: eight numbered tiles in a three-by-three frame, and one gap. Each arrangement is a state; an action slides a tile into the gap. The goal is the tiles in order. That is a search problem: states, actions with costs, a start and a goal test. A solution reaches the goal; an optimal one does so most cheaply. The eight-puzzle has a hundred and eighty-one thousand four hundred and forty reachable states, exactly half of all arrangements: a parity argument rules out the other half.
The simplest strategy is breadth-first search: everything one move away, then two, ring by ring, with the frontier in a first-in, first-out queue. Run from the goal, it maps the whole puzzle. The rings swell: the widest, at distance 24, holds 24,047 states. Every state is solvable in at most 31 moves, and exactly 2 need all 31. Breadth-first search finds shortest solutions, because it finishes each depth before the next. The price is memory: the whole frontier.
Search strategies differ only in which frontier state they expand next. Breadth-first takes the oldest. Depth-first takes the newest, diving down one branch before backing up: a stack instead of a queue. With b choices per state and a solution d moves deep, breadth-first may store about b to the d states. Depth-first stores about b times m, where m is the deepest level it explores, which need not be the shallowest solution depth: it can dive forever. Iterative deepening, used earlier in chess and analysed by Richard Korf in 1985, gets both: depth-first to depth one, then two, then three. On an exponentially branching tree the repeated work is small, because the last level dominates.
When actions have different costs, expand the cheapest first: the state with the smallest g, the cost of the best path found to it. On a graph this is Edsger Dijkstra's algorithm of 1959. Here it runs on a map: start in the middle, goal to the right behind a wall, each move costing its length. The expanded region grows as a wavefront, bending around the walls. It reaches the goal after expanding 2,636 cells, with a provably shortest path. But it searched just as far away from the goal as toward it. It knows how far it has come, not where it is going.
3A*Undergraduate4 min
In 1968 Peter Hart, Nils Nilsson and Bertram Raphael, at the Stanford Research Institute, needed Shakey, the first mobile robot to plan its own moves, to find paths quickly. Their algorithm, A star, orders the frontier by f equals g plus h. g is the cost so far, as in Dijkstra's algorithm. h is a guess at the cost still to go: a heuristic. On a map, the straight-line distance to the goal.
Here are the two searches on the same map. Dijkstra spreads in every direction; A star's frontier leans toward the goal, flows around the wall, and stops. Both reach the same optimal cost, . Dijkstra expanded cells; A star, . Their shapes are no accident. Call the optimal cost C star. Dijkstra only expands cells with g at most C star, and no path beats a straight line, so they lie in a circle of radius C star. A star only expands cells whose g plus h is at most C star, including possible boundary ties, so they lie in an ellipse with the start and the goal as its foci. We checked every expanded cell: percent inside the circle, percent inside the ellipse.
Why is A star's path the shortest? Call h admissible if it never overestimates: h of n is at most h star of n, the true cost to a goal, and h is zero at goals. In tree search, or graph search that reopens a state when a cheaper path is found, A star is optimal. Suppose a worse goal, G two, sits on the frontier. Some state n on an optimal path is on the frontier too. Its f is g plus h, at most g plus h star, because h is admissible, which is exactly C star, because n lies on an optimal path. G two costs more than C star, and its h is zero. So n always comes off the frontier first, and the optimal goal before G two.
To avoid reopening states on graphs, A star wants a little more. Call h consistent if, for every step from n to n prime, h of n is at most the step's cost plus h of n prime: a triangle inequality, which the straight-line distance obeys. Then f never decreases along a path. f of n prime is g of n, plus the step, plus h of n prime; by consistency, at least g of n plus h of n: f of n. So states come off the frontier in order of f, and the first time A star expands a state, it has its best path.
One map proves little, so we ran random ones. The median expansion counts are for Dijkstra and for A star. The median of their paired work ratios is percent, for the same optimal costs. Weight h by two, and weighted A star expands a median of , with paths percent longer on average, never more than twice the optimum. Greedy search ignores g altogether: cells, but paths percent longer, with no guarantee. Speed against optimality.
4Where heuristics come fromMaster's4 min
A star is only as good as its heuristic. Where do good ones come from? Write down the eight-puzzle's rule: a tile can move from square A to square B if A is next to B, and B is empty. Now cheat. Drop 'B is empty', and each tile walks home through the others: that easier puzzle costs the sum of the tiles' row and column distances, the Manhattan distance. Here, 16. Drop both conditions, and each misplaced tile jumps home in one move: the cost is the number of misplaced tiles, here 8. The real answer, from our breadth-first map: 20 moves. This is the general recipe, made explicit by Judea Pearl in the early nineteen-eighties: relax the problem until it is easy, and solve that exactly. Removing rules can only shorten solutions: admissible, for free.
How much does the better guess buy? A star on the eight-puzzle, up to a hundred positions per solution length. With no heuristic, at length , it expands states on average. Counting misplaced tiles: . The Manhattan distance: . The effective branching factor, the branching of a uniform tree of the same size and depth, falls from to to : each step toward one is an exponential saving. The Manhattan distance is never below the misplaced count. For consistent heuristics, dominance cannot increase the states with f below the optimal cost that A star must expand. At the boundary, equal f values and tie breaking can change the total.
The fifteen-puzzle has about ten trillion states, too many to map. In 1985 Richard Korf solved random instances optimally with IDA star: A star's ordering, run as depth-first searches with a rising bound on f, in almost no memory. Here it is on scrambled positions. Using misplaced tiles, runs out of reach our cap of generated positions. The graph omits positions whose optimal length no run established. With Manhattan distance, runs hit their cap. A more informed heuristic can come from solving a smaller relaxed puzzle exactly and remembering the answers: track five tiles, ignore the rest, and breadth-first search gives the exact cost of homing them from every placement. That is a pattern database, Joseph Culberson and Jonathan Schaeffer's idea. Each table counts only moves of its own five tiles; moves of other tiles are free. The groups are disjoint, so each real move is charged to just one table, and the three costs can be added. The pattern database hits its cap times. It knows more about the relaxed problem: on a random position it guesses moves on average, against and .
The same idea scaled up. In 1997 Korf found optimal solutions to Rubik's cube with pattern databases. In 2019 a group at Irvine let a neural network learn the heuristic instead, and used it inside weighted A star: it solved every test cube, with a shortest solution sixty point three percent of the time. A learned estimate of the cost to go is what reinforcement learning calls a value function, and search guided by one is how AlphaZero plays, in Part 26.
5Climbing and coolingMaster's4 min
Often the path doesn't matter, only the final state: a schedule, a chip layout, a tour. Then keep a single state and improve it step by step. Picture the states as a landscape, height meaning quality. Hill climbing always steps to the best neighbour. It is fast and needs almost no memory. And it stops on the first peak it reaches, a local maximum, while the highest peak is somewhere else.
The classic test: eight queens on a chessboard, none attacking another. One queen per column; a move shifts a queen within its column; the height is the number of attacking pairs. Two runs of steepest descent. On the left, the attacks fall, then stop: no move helps. On the right, the same rule reaches a solution. Over 10,000 random starts it solves 14 percent, in 4 steps on average; the rest get stuck after 3. Allow sideways moves across plateaus, and it solves 95 percent. Or restart whenever stuck: about 7 tries, around 23 steps in all.
Simulated annealing escapes local optima by sometimes going the wrong way. Propose a random change. If it lowers the cost, take it; if it raises the cost by delta E, take it anyway with probability e to the minus delta E over T, where T is a temperature. Why that rule? At a fixed temperature, choose detailed balance: equal probability flow between each pair of states. Uphill moves are accepted with that probability, downhill always, and proposals are symmetric. Divide, and Boltzmann's distribution is stationary. With enough mixing, visits follow that distribution. Its equilibrium mass concentrates on minimum cost as T falls toward zero. A finite cooling run need not stay in equilibrium or reach the optimum.
Here it is on a travelling-salesman problem: the shortest round trip through fifty-two places in Berlin, a standard test whose optimum is known. A move reverses a stretch of the tour. Hot, at first, percent of proposed changes are accepted, and the tour is a tangle. As it cools, fewer bad moves get through; crossing edges disappear, and the tour pulls into loops around the city's clusters. At the end, percent are accepted: annealing has become hill climbing, from a very good place.
Is the cooling worth it? Limit all three methods to the same number of candidate-cost evaluations, including initialization. A two-opt delta counts once, like scoring one genetic child; this is not equal CPU time. The greedy tour, always to the nearest unvisited place, is percent too long even from its best start. After polishing every start's tour with 2-opt, the best result is , potentially from a different start.
A third idea keeps a whole population. John Holland's genetic algorithms, from 1975, let the fitter states reproduce: a child takes pieces of two parents, plus a random mutation. On our budget, a plain version ends percent above the optimum. Crossover and mutation can disrupt good tour segments. Population search has a second life. DeepMind's FunSearch, in 2023, let a language model propose the mutations; in 2025 AlphaEvolve evolved programs that way, and found how to multiply four-by-four complex matrices with forty-eight multiplications, one fewer than Strassen's 1969 method.
6Games and alpha-betaUndergraduate4 min
Games were the field's favourite test: clear rules, a clear score, and an opponent who fights back. In 1928 John von Neumann proved that in a two-player zero-sum game, each side can guarantee a value by assuming the opponent plays perfectly. So look ahead: where you move, take the maximum; where the opponent moves, the minimum. That's minimax. In 1950 Claude Shannon described a chess program built this way, with a formula to score the positions at the end of the look-ahead, and estimated some ten to the hundred and twenty possible games: far too many to search to the end. Tic-tac-toe is small enough. Our minimax visits 549,946 positions and 255,168 complete games, and finds the game is a draw with best play.
Much of a game tree can be skipped. Here is a small one: you move, they reply, you move, and the bottom positions are scored. Search it depth-first, carrying two numbers: alpha, the best you are already sure of, and beta, the best your opponent is sure of. As soon as a reply shows a move is worse than one you already have, that move's other replies cannot matter, and are skipped. The greyed branches are never examined: of the positions, and the answer at the top is still exactly minimax's. This is alpha-beta pruning, suggested by John McCarthy in the mid-nineteen-fifties and used by generations of alpha-beta chess engines. Scores at cutoffs can be bounds rather than exact values; we mark those with an inequality. The root answer is exact.
How much can pruning save? Donald Knuth and Ronald Moore analysed it in full in 1975. To prove a position is worth exactly v, you need two bounds. At least v: one good move of yours, and every reply to it, at every level: b to the d over two leaves, rounded down. At most v: every move of yours, and one refutation of each. The two proofs share one line of play. So with perfect ordering, alpha-beta evaluates about twice the square root of the full tree: twice as deep for the same work. We checked on uniform trees with perfect ordering: five moves per position, eight deep, 1,249 leaves out of 390,625, exactly the formula; all 32 cases agree.
On a real game the savings are as large. Connect Four, deeper and deeper. Plain minimax grows about sevenfold per move: at depth 9, 37.5 million positions. Alpha-beta in random order: 178,351. Best-looking move first: 17,527. With an oracle that knows the truly best move, at depth 8: 4,620, the order of the square root of minimax's 5,655,958. That is why move ordering became the chess programmer's craft.
7Machines that learned to playMaster's4 min
In 1959 Arthur Samuel of IBM published a checkers program with a striking claim: that a computer can be programmed so that it will learn to play a better game of checkers than can be played by the person who wrote the program. It searched a few moves ahead and scored positions with a weighted sum of board features: a scoring polynomial. What was new: it adjusted the weights itself, by playing. In 1962 it beat a Connecticut player, Robert Nealey, in a famous game; Nealey won the rematch, and in 1966 the program lost all eight games against the world champions. But the idea mattered, and Samuel helped popularize the very words machine learning.
Samuel's delta idea is a seed of modern reinforcement learning. We write a modern semi-gradient analogue here; his original program adjusted sign correlations and quantized coefficients instead. Keep the static score your evaluation gave your previous position. Two moves later, search from the new position and back up a score: a better-informed opinion of the same game. The difference, Samuel's delta, says how wrong the old score was. Nudge the weights to shrink it. Two copies played: Alpha learned, Beta kept its weights, and when Alpha won, Beta took them. Richard Sutton built on this idea when he formalized temporal-difference learning in 1988.
We gave Samuel's method a game of our own: Connect Four, five features a programmer might choose, and a search three moves deep. Alpha starts with every weight zero. Here are its weights as it plays; in orange, the weights we set by hand before training. Over games against Beta, the weights find their places. At intervals we froze Alpha and played it against two fixed opponents: the untrained player, and our hand-set weights.
After games, in each of runs: The curves were not smooth: Samuel saw his program wander too, and sometimes had to reset it by hand.
Chess went the other way: more search, more hand-crafted knowledge. In 1996 Garry Kasparov beat IBM's Deep Blue four games to two, and the team doubled the machine. In the 1997 rematch it ran four hundred and eighty custom chess chips, averaging a hundred and twenty-six million positions a second, with an evaluation of about eight thousand features, almost all tuned by hand. It won three and a half to two and a half. Search plus a human-designed sense of a good position: Shannon's recipe of 1950, at enormous scale.
Checkers itself was finished off by search. Jonathan Schaeffer's Chinook became the first program to win a human world championship, in 1994. In 2007 his team proved that checkers, with about five times ten to the twenty positions, is a draw with perfect play. The game that resisted the recipe was Go, where nobody could write down a good evaluation. That took a learned one: Part 26.
8Logic and resolutionMaster's3 min
The other great idea of the era was logic: write down what you know, and let the machine work out what follows. Three facts. If it rains, the grass is wet. If the sprinkler is on, the grass is wet. It is raining, or the sprinkler is on. Does it follow that the grass is wet? List every combination of true and false. In every row where all the facts hold, Wet holds too: the facts entail it. But n symbols make two to the n rows. We need to derive conclusions, not enumerate worlds.
Real knowledge needs more. First-order logic, from Gottlob Frege in 1879, adds objects, relations, and the words all and some: for all x, y and z, if x is a parent of y and y of z, then x is a grandparent of z. Kurt Gödel proved in 1930 that every valid first-order sentence has a proof, so a machine searching through proofs will find one. But no program can decide validity in general: if the answer is no, the search may never end.
In 1965 Alan Robinson gave machines a resolution rule for automated deduction. Write every fact as a clause, an or of literals. If one clause contains x and another not x, resolve them: at least one of the rest must hold. To prove a goal, add its negation, here: the grass is not wet, and resolve until you derive the empty clause, a contradiction. Not wet and the rain rule give no rain; not wet and the sprinkler rule give no sprinkler; rain or sprinkler, with no sprinkler, gives rain; rain against no rain leaves nothing. Robinson proved the method sound and refutation-complete. First-order clauses also need factoring: unify same-sign literals within one clause. Without a resource cap, resolution and factoring can derive the empty clause whenever the clauses are inconsistent. Our bounded run can stop without an answer.
With variables, resolution needs one more step. The negated goal can be resolved with the rule only after the rule's variables are matched to Anne and Ada. Finding the most general such substitution is unification, the other half of Robinson's paper. Two more steps, and the empty clause. Restrict clauses to at most one positive literal, and resolution becomes a programming language: Prolog, created by Alain Colmerauer and Philippe Roussel in Marseille in 1972, with Robert Kowalski's theory behind it.
Completeness is not efficiency. Give the prover eight family facts and three rules, and ask whether Anne is an ancestor of Flora, four generations away. The set-of-support strategy, from Larry Wos and colleagues in 1965, resolves only pairs involving the negated goal or its descendants. Provers live or die by such strategies. Resolution's descendants, like Vampire and E, still compete every year, and proof assistants call on them to fill in routine steps.
9SatisfiabilityResearch3 min
Strip logic down to its core and you get one problem. Given clauses, each an or of variables or their negations, can every variable be set true or false so that every clause holds? That is satisfiability, SAT. In 1971 Stephen Cook, and independently Leonid Levin, showed that any problem whose solutions can be checked quickly can be rewritten as SAT: the first NP-complete problem. And yet SAT solvers became one of AI's great practical successes.
The classic method is DPLL, from Martin Davis and Hilary Putnam in 1960, made practical with George Logemann and Donald Loveland in 1962. Propagate: a clause with one literal left open forces it. When nothing is forced, branch: pick a variable, try true, propagate. If a clause has every literal false, back up and try the other value. On our little formula:
In 1992 David Mitchell, Bart Selman and Hector Levesque asked what random formulas look like: n variables, m clauses of three random literals. With few clauses per variable, almost every formula is satisfiable; with many, almost none; in between, the chance drops off a cliff. As n grows, the step becomes a jump, near a ratio of four point two seven. Physicists predicted 4.267 with a method from the theory of disordered magnets; mathematicians have proved the threshold lies between 3.52 and 4.49. A phase transition, like water freezing, in a logic problem.
The transition is also where the problems are hard. Count DPLL's decisions: far below the threshold a solution is found almost at once, far above, a contradiction.
Modern solvers add one idea: learn from every mistake. Here a solver has made four decisions, one per level, and propagation has implied a cascade, each arrow from the literals that forced it. It ends in a conflict. DPLL would just undo the last decision. Conflict-driven clause learning asks why: it traces the conflict back to the first point every path passes through, here x 4. The reasons become a new clause, implied by the formula, that rules out this combination forever. Then the solver jumps back, past irrelevant decisions, to level 3. With clever branching and cheap bookkeeping, from GRASP in 1996 and Chaff in 2001, every competitive solver works this way.
Learning is not a small improvement. Ask whether two circuits for adding binary numbers ever disagree, written as clauses that are satisfiable exactly when they do. DPLL, remembering nothing, needs about 4 times as many decisions for every extra bit: 19,254,403 for 12-bit adders. Our clause-learning solver needs 440 conflicts, up from 13 at 2 bits, and proves two 64-bit adders equal on all two to the 128 inputs with 6,979 conflicts.
10Constraints and plansMaster's4 min
Many problems are sets of constraints rather than paths. A constraint satisfaction problem has variables, each with a domain of values, and constraints that rule out some combinations. A Sudoku: eighty-one cells, each one to nine, all different in every row, column and box. Such structure invites propagation: David Waltz used it in 1975 to label the lines of drawings, and Alan Mackworth gave the general algorithm in 1977.
Arc consistency looks at one constraint at a time. For each pair of cells that must differ, delete any value of the first that the second leaves no room for; when a cell shrinks, recheck its neighbours. Every clue knocks its value out of its row, column and box, and the deletions cascade. AC-3 deletes 313 values and settles 3 more cells, but not the puzzle: propagation alone is not enough here. With search, it is decisive. Plain backtracking in reading order tries 3,642 assignments; forward checking, 1,669; also choosing the cell with the fewest values left, 182; full arc consistency after every choice, 93.
Planning is search where the states are descriptions. STRIPS, from Richard Fikes and Nils Nilsson in 1971, for Shakey the robot, describes a state as a set of facts, and an action by three lists. To stack x on y you must hold x, and y must be clear; afterwards x is on y, x is clear and the hand is empty, and you no longer hold x, nor is y clear. Why a delete list? The frame problem, posed by John McCarthy and Patrick Hayes in 1969: in pure logic, an action must also state everything it leaves unchanged, which is almost everything. STRIPS simply assumes that whatever an action doesn't mention stays as it was.
Early planners solved goals one at a time. Gerald Sussman found the simplest case where that fails. C sits on A; B is on the table. The goal: A on B, and B on C. Put A on B first: clear C off A, put it down, stack A on B. Now B must go on C, and moving B means taking A off again, undoing the first goal. The shortest plan, found by breadth-first search, has steps and interleaves the two goals.
And the search space explodes. blocks can be stacked different ways. The cure is chapter four's idea: relax the problem. Ignore delete lists, then compute cheap approximations to the remaining cost; finding the shortest relaxed plan is still NP-hard. With admissible h max, A* returns an optimal plan when it solves this unit-cost task. Inspired by Hoffmann and Nebel's FF planner of 2001, our FF-style heuristic counts distinct actions in an extracted relaxed plan. The matched comparison is this: Check completion as well: Such heuristics, Graphplan, and planning as satisfiability made general planners practical.
11Knowledge is powerEngineering4 min
Search and logic need something to reason about. Ross Quillian's semantic networks, from 1968, store concepts as nodes and relations as links: a canary is a bird, a bird is an animal. Properties are stored once and inherited: does a canary breathe? Follow the is-a links up to animal. Exceptions sit lower down: a penguin is a bird that does not fly. Marvin Minsky's frames, in 1974, bundled a concept's slots with default values. These ideas live on as the objects and classes of programming languages.
In the seventies a new kind of program captured the field: the expert system, its knowledge a set of if-then rules written with human experts. Give it facts about an animal. Forward chaining fires every rule whose conditions hold, adds the conclusion, and repeats: hair makes a mammal; a mammal with pointed teeth and claws, a carnivore; a tawny carnivore with dark spots, a cheetah. The first great one was DENDRAL, begun at Stanford in 1965 by Edward Feigenbaum, Bruce Buchanan and Joshua Lederberg, which inferred molecular structure from mass spectra. Feigenbaum's lesson: a program's power comes from what it knows, more than from how cleverly it reasons.
Medicine was the showcase. MYCIN, built at Stanford by Edward Shortliffe in the mid-seventies, recommended antibiotics for blood infections and meningitis from a few hundred rules like this one. Each rule carried a certainty factor; when rules agreed, new evidence closed part of the remaining gap. Point six and point five make ; another rule at point four, . In a blinded test published in 1979, eight experts rated antibiotic choices for ten meningitis cases. MYCIN received an acceptability rating of sixty-five percent, a rate none of the Stanford specialists it was compared with beat. It was never used on patients. The commercial breakthrough was R1, later XCON, written by John McDermott for Digital Equipment in 1980 to configure computer orders. By the mid-eighties, expert systems were an industry.
The weak point was getting the knowledge in. An expert talks; a knowledge engineer writes rules; the rules fail and are patched, for months per domain, and as they multiply they interact in ways nobody intended: the knowledge acquisition bottleneck. And the systems were brittle: faced with a case no rule covers, a human expert does something sensible; a rule base does nothing, or something absurd. Douglas Lenat drew the boldest conclusion: write down common sense itself. His Cyc project, started in 1984, has entered millions of assertions by hand, and still runs.
Knowledge as a web of entities and relations did not die; it scaled. In 2012 Google introduced its Knowledge Graph, things, not strings: over five hundred million objects and three and a half billion facts at launch, harvested from sources like Wikipedia rather than typed in. Knowledge graphs answer factual questions in search engines today. What changed was not the representation, but where the knowledge comes from.
12ELIZAUndergraduate2 min
In 1966 Joseph Weizenbaum at MIT published a program that held conversations: ELIZA, named after the flower girl in Pygmalion. Its famous script, DOCTOR, plays a psychotherapist who turns your statements into questions. Type: my mother takes care of me. ELIZA swaps the pronouns, and finds its highest-ranked keyword, here my, with a pattern: anything, your, anything, a family word, anything. It takes the next of that pattern's reassembly rules, and splices the matched pieces in. Who else in your family takes care of you. No grammar, no meaning: pattern matching and a few hundred lines of script.
Weizenbaum's paper printed a conversation with DOCTOR. We wrote a small ELIZA from the paper's description, with our own short script, and gave it the user's side, line by line. of its replies come out word for word as in 1966. Note the trick: when nothing matches, ELIZA brings back something you said earlier. It reads as attention, even memory.
Step outside the therapist's frame and the trick shows. Ask a fact, and it asks why you ask. Ask for a proof, and it hands your sentence back, pronouns turned around. Mention a computer, and a rule written for exactly that fires. Nothing is understood; the illusion lives in the reader.
What disturbed Weizenbaum was how people responded. In his 1976 book, Computer Power and Human Reason, he recalled his secretary, who had watched him write the program, asking him to leave the room so she could talk to it in private, and wrote that he had not imagined so short an exposure to so simple a program could produce such powerful delusions in normal people. Reading understanding into fluent output became known as the ELIZA effect. His original code was found at MIT in 2021 and run again in 2024. A separate Python implementation of the DOCTOR script was used in the 2025 Turing tests, and people took it for human in twenty-three percent of conversations. Does fluency mean understanding? Every chatbot raises the question again.
13The wintersUndergraduate4 min
The founders had promised a great deal, soon. By the late sixties the bills came due. In 1966 an advisory committee told the US government that machine translation was slower, less accurate and costlier than human translators, and its funding dried up. In 1969 Minsky and Papert's book Perceptrons laid out the limits of one-layer neural networks, and that line went quiet for a decade. In 1973 the mathematician James Lighthill told Britain's Science Research Council that outside toy problems, AI was defeated by the combinatorial explosion: the very search spaces we have been counting. He defended his report on television against Donald Michie, John McCarthy and Richard Gregory. British funding shrank to a few centres; in America, DARPA turned to military goals. The first winter lasted until about 1980.
Expert systems brought the money back. Companies built their own; in 1982 Japan launched a ten-year Fifth Generation project around logic programming, and America and Britain answered. A small industry sold Lisp machines, workstations built to run AI software. In 1984 Roger Schank and Marvin Minsky warned the American AI association that enthusiasm had outrun results, and named what would follow: an AI winter. In 1987 the Lisp-machine market collapsed, undercut by ordinary workstations; expert systems proved costly to maintain and brittle; the Fifth Generation project ended in 1992 short of its goals. The second winter set in, and for years researchers avoided the words artificial intelligence.
Beneath the funding story lay a scientific surprise. Symbolic programs did best at what people find hard: logic, algebra, chess. They did worst at what any child does without effort: seeing, walking, grasping, understanding speech, common sense. Hans Moravec observed in 1988 that it is comparatively easy to make computers match adults on intelligence tests or at checkers, and hard or impossible to give them the perception and mobility of a one-year-old. Evolution, he argued, spent hundreds of millions of years on perception and movement; abstract reasoning is a thin, recent layer. This is Moravec's paradox.
There is a measurable reason hand-written knowledge kept running out, and we can see it in the thirty novels of Part 1. Rank their words from most to least common. The top 76 words make up half the text. Ninety percent takes 4,177; ninety-nine, 28,193; ninety-nine point nine, 55,313. 21,797 of the 59,639 different words occur exactly once. And fresh text brings new ones: in the series' test passage, 2.8 percent of the words never appear in 4.3 million words of novels. Language, vision and the physical world all have this shape: a few common cases, and an endless tail of rare ones. A rule for each case never finishes. What finishes is a method that learns from data, and generalizes to cases nobody wrote down. That is where this course goes next.
14What survivesEngineering4 min
The symbolic era ended, but its machinery did not. Deep Blue was search plus an evaluation written by people. Twenty years later AlphaZero kept the search, Monte Carlo tree search instead of alpha-beta, and learned its evaluation by playing itself, examining about a thousand times fewer positions per second than the chess engine it beat. Search guided by an evaluation is the skeleton of both. Part 26 builds one.
Logic found its biggest job in checking machines. In 1994 a flaw in the Pentium's division circuit, a few missing table entries, cost Intel a four-hundred-and-seventy-five-million-dollar charge, and chip makers turned to formal verification, with SAT solvers among its engines. Our own small solver proves two 64-bit adders equal on all two to the 128 inputs, with 6,979 conflicts. Slip one wire at bit 6, and it finds an input where they disagree: 24,443 plus 54,316 should give 13,223 in 16 bits; the faulty circuit says 13,095. Add theories of arithmetic and data structures and you get SMT solvers like Microsoft's Z3; Amazon reported in 2022 running over a billion SMT queries a day to check who can access what.
There are limits. Ask the same solver whether the low product bits agree for a times b and b times a. In these runs the conflicts grow about -fold with every extra input bit: at bits. This is a search difficulty, not proof that short proofs do not exist. Multipliers are a famous hard case for SAT solvers; specialized algebraic methods can help.
Logic's other modern home is mathematics. In a proof assistant like Lean, a small trusted program checks every step, so a proof that compiles is correct. DeepMind's AlphaGeometry, in 2024, paired a language model that suggests constructions with a symbolic deduction engine. AlphaProof ran AlphaZero-style search over Lean proofs; with AlphaGeometry 2, it solved four of six problems at the 2024 International Mathematical Olympiad, silver-medal level. A year later a Gemini model reached a gold-medal score writing plain language, graded by the olympiad's coordinators. Either way: a network generates, and logic or a grader checks.
Planning is back, inside language-model agents. On PlanBench, built from the blocks world, the best ordinary language model tested in 2024 solved sixty-three percent of problems, and OpenAI's reasoning model o1-preview ninety-eight. Rename the blocks and actions to nonsense words, logic unchanged, and o1-preview fell to fifty-three percent; a classical planner solves every instance, whatever the names. One practical answer combines them: given a domain model, the language model writes the problem in the planning language PDDL, and a classical planner finds a plan valid in that formal model. The guarantee applies to the model; its assumptions and the language model's translation still need checking.
So the old argument, symbols or learning, ended in a merger. Networks bring what the symbolic era lacked: perception, intuition, guesses from data. Symbols bring what networks cannot promise: exhaustive search, exact logic, guarantees. Today's strongest systems let a network propose and a symbolic process check: AlphaZero, AlphaProof, FunSearch and AlphaEvolve, agents that call tools. This is neurosymbolic AI, and we will meet it again in reinforcement learning, reasoning models and agents.
Recap, problems, and where this comes backAll tracks2 min
Let's take stock. Turing defined what machines can compute, and what they cannot. Search finds solutions by trying things; A star, with an admissible heuristic, finds the cheapest and can greatly reduce the search, and effective heuristics often come from relaxed problems. Annealing's controlled randomness escapes local optima. With excellent move ordering, alpha-beta can search roughly twice as deep for the same work. Logic reduces to resolution and satisfiability, whose hard problems live at a phase transition, and clause learning makes solvers fast. And knowledge written by hand runs into the long tail, which is why the field turned to learning.
All of this comes back. Learned weights replace hand-written rules with the perceptron and backpropagation, in Part 9. Search guided by a learned evaluation is AlphaZero, in Part 26. Search over chains of thought, rewarded by checkable answers, makes the reasoning models of Part 28. Planning and tools return in the agents of Part 29. And verification, proof, and who checks the checker close the series in Part 31.
Here are six problems to try, from consistent heuristics to the satisfiability threshold. Pause here, and work through them; full solutions are in this part's notes.
Next time: meaning as geometry. To a symbol, cat is as far from dog as from car. Part 3 turns words into vectors, where nearness means similarity, and builds the linear algebra every model in this course runs on: inner products, eigenvalues, the singular value decomposition.
Russell and Norvig's textbook is the place to go deeper: everything in this part is in it. For the history, Nils Nilsson's The Quest for Artificial Intelligence. Thanks for watching, and see you in Part 3.
Where it goes next. Learned weights replace hand-written rules in Part 9. Search guided by a learned evaluation is AlphaZero in Part 26, which also solves Connect Four; search over chains of thought returns in Part 28, planning and tools in Part 29, and proof and verification in Part 31.
Key results
The part's results in one place, for revision.
Try it
Lab 2 · Alpha-beta: the same move from far fewer leaves
Build uniform game trees with random leaf values, search them with minimax and with alpha-beta under three move orders (best first, random, worst first), and check that every search returns the same value while best-first ordering examines exactly b^ceil(d/2) + b^floor(d/2) - 1 leaves.
python -m videos.ai.labs 2
needs numpy, scipy, matplotlib · download lab02.py ·
source on GitHubb = 2, d = 10: minimax examines 1024 leaves
b = 2, d = 10: alpha-beta, best first 63 (formula 63); random order 219; worst first 837
b = 3, d = 7: minimax examines 2187 leaves
b = 3, d = 7: alpha-beta, best first 107 (formula 107); random order 496; worst first 1780
b = 4, d = 6: minimax examines 4096 leaves
b = 4, d = 6: alpha-beta, best first 127 (formula 127); random order 838; worst first 3593
b = 6, d = 4: minimax examines 1296 leaves
b = 6, d = 4: alpha-beta, best first 71 (formula 71); random order 490; worst first 1244
b = 3: growth per ply minimax 3.00 worst first 2.80 random order 2.23 best first 1.74 (sqrt 3 = 1.73)
Alpha-beta never changes the answer, only the work: with the best move tried first the tree's effective branching factor falls from b to its square root, so the same work searches twice as deep; a random order lands in between.
The code (120 lines; it asserts its own result)
"""Lab 2: count the leaves minimax and alpha-beta examine on uniform game trees, against Knuth and Moore's formula."""
import numpy as np
from videos.coursekit import labs
TITLE = "Alpha-beta: the same move from far fewer leaves"
GOAL = ("Build uniform game trees with random leaf values, search them with minimax and with alpha-beta under three "
"move orders (best first, random, worst first), and check that every search returns the same value while "
"best-first ordering examines exactly b^ceil(d/2) + b^floor(d/2) - 1 leaves.")
TASKS = [
"Order the moves by a noisy guess of their value (true value plus noise of sd 0.1, 0.3, 1). How good must the "
"guess be to stay near the best case?",
"Draw the leaf values from {0, 1} instead of a continuum (a win/loss game). Why can alpha-beta now examine "
"fewer leaves than the formula?",
"Add iterative deepening: search to depth 1, 2, ..., d, ordering each level by the previous search's values, "
"and count the total leaves against one random-order search to depth d.",
]
def minimax_values(leaves, b, d):
"""The minimax value of every node, level by level: values[k] holds the b^k nodes at depth k (root maximizes)."""
values = [None] * (d + 1)
values[d] = leaves
for k in range(d - 1, -1, -1):
children = values[k + 1].reshape(-1, b)
values[k] = children.max(axis=1) if k % 2 == 0 else children.min(axis=1)
return values
def alphabeta(values, b, d, order, rng=None):
"""Alpha-beta from the root; ``order`` is 'best', 'worst' or 'random'. Returns (value, leaves examined)."""
count = 0
def visit(k, i, alpha, beta):
nonlocal count
if k == d:
count += 1
return values[d][i]
kids = np.arange(i * b, (i + 1) * b)
if order == "random":
kids = rng.permutation(kids)
else: # sort by the children's true values: descending is best-first for the maximizer
kids = kids[np.argsort(values[k + 1][kids])]
if (order == "best") == (k % 2 == 0):
kids = kids[::-1]
if k % 2 == 0:
best = -np.inf
for c in kids:
best = max(best, visit(k + 1, c, alpha, beta))
alpha = max(alpha, best)
if alpha >= beta:
break
else:
best = np.inf
for c in kids:
best = min(best, visit(k + 1, c, alpha, beta))
beta = min(beta, best)
if alpha >= beta:
break
return best
return visit(0, 0, -np.inf, np.inf), count
def best_case(b, d):
return b ** ((d + 1) // 2) + b ** (d // 2) - 1
def run(seed=0):
rng = np.random.default_rng(seed)
lab = labs.Lab()
table = {}
for b, d in ((2, 10), (3, 7), (4, 6), (6, 4)):
values = minimax_values(rng.random(b ** d), b, d)
got = {o: alphabeta(values, b, d, o, rng) for o in ("best", "random", "worst")}
table[(b, d)] = got
lab.row(f"b = {b}, d = {d}: minimax examines", f"{b ** d} leaves")
lab.row(f"b = {b}, d = {d}: alpha-beta, best first",
f"{got['best'][1]} (formula {best_case(b, d)}); random order {got['random'][1]}; "
f"worst first {got['worst'][1]}")
for o, (value, count) in got.items():
assert value == values[0][0], f"alpha-beta ({o}) must return the minimax value"
assert got["best"][1] == best_case(b, d), "Knuth and Moore's best case, exactly"
assert best_case(b, d) < got["random"][1] < b ** d, "random order prunes, but less"
assert got["random"][1] < got["worst"][1] <= b ** d
b, depths = 3, np.arange(1, 9)
curves = {"minimax": [], "worst first": [], "random order": [], "best first": []}
for d in depths:
values = minimax_values(rng.random(b ** d), b, d)
curves["minimax"].append(b ** d)
curves["worst first"].append(alphabeta(values, b, d, "worst")[1])
curves["random order"].append(np.mean([alphabeta(values, b, d, "random", rng)[1] for _ in range(5)]))
curves["best first"].append(alphabeta(values, b, d, "best")[1])
growth = {k: (v[-1] / v[-3]) ** 0.5 for k, v in curves.items()} # leaves multiply by this per extra ply
lab.row("b = 3: growth per ply", " ".join(f"{k} {g:.2f}" for k, g in growth.items()) + f" (sqrt 3 = {3 ** 0.5:.2f})")
assert abs(growth["best first"] - np.sqrt(b)) < 0.05, "best-first ordering searches twice as deep for the same work"
assert 1.5 * curves["best first"][-1] < curves["random order"][-1] < curves["minimax"][-1] / 1.5
lab.note = ("Alpha-beta never changes the answer, only the work: with the best move tried first the tree's "
"effective branching factor falls from b to its square root, so the same work searches twice as "
"deep; a random order lands in between.")
fig, ax = labs.figure(2, size=(11, 4.2))
colors = {"minimax": labs.RED, "worst first": labs.ORANGE, "random order": labs.BLUE, "best first": labs.GREEN}
for name, ys in curves.items():
ax[0].plot(depths, ys, "o-", ms=4, color=colors[name], label=name)
ax[0].plot(depths, [best_case(b, d) for d in depths], "--", color=labs.INK, lw=1,
label=r"$b^{\lceil d/2\rceil}+b^{\lfloor d/2\rfloor}-1$")
ax[0].set(title="Leaves examined, branching factor 3", xlabel="depth d (plies)", ylabel="leaves", yscale="log")
ax[0].legend()
labels = [f"b={b}, d={d}" for b, d in table]
x = np.arange(len(table))
for k, (o, color) in enumerate((("worst", labs.ORANGE), ("random", labs.BLUE), ("best", labs.GREEN))):
share = [table[key][o][1] / key[0] ** key[1] for key in table]
ax[1].bar(x + (k - 1) * 0.26, share, 0.26, color=color, label=f"{o} first" if o != "random" else "random order")
ax[1].set(title="Share of the tree's leaves alpha-beta examines", ylabel="fraction of minimax's leaves", ylim=(0, 1.05))
ax[1].set_xticks(x, labels)
ax[1].legend()
lab.fig = fig
return lab
Now change it
- Order the moves by a noisy guess of their value (true value plus noise of sd 0.1, 0.3, 1). How good must the guess be to stay near the best case?
- Draw the leaf values from {0, 1} instead of a continuum (a win/loss game). Why can alpha-beta now examine fewer leaves than the formula?
- Add iterative deepening: search to depth 1, 2, ..., d, ordering each level by the previous search's values, and count the total leaves against one random-order search to depth d.
Problems, with solutions
Try each problem before opening its solution.
1. Manhattan is consistent. Show that the Manhattan-distance heuristic of the 8-puzzle is consistent.
Solution
A move slides one tile to a neighbouring square, changing that tile's row or column by one and leaving every other tile where it was. So h changes by exactly ±1 while the step costs 1: h(n) ≤ 1 + h(n′) for every move n → n′, and h = 0 at the goal. That is consistency.
2. Consistent implies admissible. Prove that a consistent heuristic is admissible, and give an admissible heuristic that is not consistent.
Solution
Induction on the number k of steps in an optimal path from n to a goal. For k = 0, n is a goal and h(n) = 0 = h*(n). Otherwise let n → n′ be the first step of an optimal path; then h(n) ≤ c(n, n′) + h(n′) ≤ c(n, n′) + h*(n′) = h*(n). For the converse, take a path s → a → g with both steps of cost 1, and h(s) = 2, h(a) = 0, h(g) = 0. It never overestimates (h*(s) = 2, h*(a) = 1), but h(s) = 2 > c(s, a) + h(a) = 1.
3. Alpha–beta's best case. With the best move always searched first, show that alpha–beta on a uniform tree of branching b and depth d evaluates exactly b^⌈d/2⌉ + b^⌊d/2⌋ − 1 leaves.
Solution
With perfect ordering the nodes searched are of three types (Knuth & Moore). The root is type 1; a type-1 node searches all its children, the first of type 1 and the others of type 2; a type-2 node searches only its first child, which refutes it, of type 3; a type-3 node searches all its children, each of type 2. Let N₁, N₂, N₃ count the leaves below a node of each type at height d. Then N₂(d) = N₃(d − 1), N₃(d) = b N₂(d − 1), so N₂(d) = b^⌊d/2⌋ and N₃(d) = b^⌈d/2⌉; and N₁(d) = N₁(d − 1) + (b − 1) N₂(d − 1) = N₁(d − 1) + (b − 1) b^⌊(d−1)/2⌋ with N₁(0) = 1. Checking d = 2k and d = 2k + 1 separately, b^⌈d/2⌉ + b^⌊d/2⌋ − 1 satisfies the same recursion and the same start, so it equals N₁(d). (The two terms are the two proofs of the chapter: one move of yours against every reply, and every move of yours against one refutation; they share one leaf.)
4. Why annealing works. Show that the Metropolis rule (symmetric proposals q; accept a move up by ΔE with probability e^{−ΔE/T}, a move down always) satisfies detailed balance for π(s) ∝ e^{−E(s)/T}, and that as T → 0 the distribution concentrates on the global minima.
Solution
Take s, s′ with E(s′) > E(s). Then P(s → s′) = q e^{−(E(s′) − E(s))/T} and P(s′ → s) = q, so π(s) P(s → s′) = (q/Z) e^{−E(s′)/T} = π(s′) P(s′ → s); equal energies are trivial. Detailed balance makes π stationary (and the unique stationary distribution if the moves connect all states). For a state s and a global minimum s*, π(s)/π(s*) = e^{−(E(s) − E*)/T} → 0 as T → 0 whenever E(s) > E*, so all the probability ends on the global minima, shared equally.
5. Resolution. Show that a resolvent is entailed by its parents, and refute {P ∨ Q, ¬P ∨ Q, P ∨ ¬Q, ¬P ∨ ¬Q}.
Solution
Suppose an assignment satisfies A ∨ x and B ∨ ¬x. If x is true, the second clause forces B; if x is false, the first forces A; either way A ∨ B holds. Refutation: P ∨ Q and ¬P ∨ Q give Q; P ∨ ¬Q and ¬P ∨ ¬Q give ¬Q; Q and ¬Q give the empty clause. The set is unsatisfiable.
6. An upper bound on the threshold. For random 3-SAT with n variables and m = αn clauses, show that the expected number of satisfying assignments is 2ⁿ (7/8)^{αn}, and deduce that the threshold is at most ln 2 / ln(8/7) ≈ 5.19.
Solution
A fixed assignment falsifies a random clause only if all three literals come out false: one sign pattern in eight. The clauses are drawn independently, so the assignment satisfies all of them with probability (7/8)^m; summing over the 2ⁿ assignments, E[X] = 2ⁿ (7/8)^{αn} = exp(n (ln 2 − α ln(8/7))). If α > ln 2 / ln(8/7) ≈ 5.19 this tends to 0, and by Markov's inequality P(X ≥ 1) ≤ E[X] → 0: almost every formula is unsatisfiable. (This first-moment argument gives only an upper bound. A large expected number of solutions need not imply a large probability of satisfiability: many assignments may be concentrated in a small fraction of formulas. The value near 4.267 is a statistical-physics prediction.)
Notes and sources
Glossary
| English | 中文 |
|---|---|
| Turing machine, tape, head, state | 图灵机,纸带,读写头,状态 |
| universal machine, stored-program computer | 通用机,存储程序计算机 |
| halting problem, decidable / undecidable | 停机问题,可判定 / 不可判定 |
| busy beaver | 忙碌海狸 |
| imitation game, Turing test, interrogator | 模仿游戏,图灵测试,提问者 |
| Dartmouth workshop | 达特茅斯会议 |
| Logic Theorist | 逻辑理论家 |
| physical symbol system hypothesis | 物理符号系统假设 |
| search problem, state space, goal test | 搜索问题,状态空间,目标测试 |
| breadth-first / depth-first search, iterative deepening | 广度优先 / 深度优先搜索,迭代加深 |
| uniform-cost search, Dijkstra's algorithm | 一致代价搜索,迪杰斯特拉算法 |
| frontier, wavefront, expand | 边界,波前,扩展 |
| heuristic, A*, f = g + h | 启发式(启发函数),A*,f = g + h |
| admissible, consistent (monotone) | 可采纳的,一致的(单调的) |
| weighted A*, greedy best-first search | 加权A*,贪心最佳优先搜索 |
| relaxed problem, Manhattan distance, misplaced tiles | 松弛问题,曼哈顿距离,错位方块数 |
| dominance, effective branching factor | 占优,有效分支因子 |
| 8-puzzle, 15-puzzle | 八数码,十五数码 |
| IDA*, pattern database | IDA*,模式数据库 |
| local search, hill climbing, local maximum, plateau | 局部搜索,爬山法,局部极大值,平台 |
| random restart, sideways move | 随机重启,横向移动 |
| simulated annealing, temperature, cooling schedule | 模拟退火,温度,降温计划 |
| Metropolis rule, detailed balance, Boltzmann distribution | 梅特罗波利斯准则,细致平衡,玻尔兹曼分布 |
| travelling salesman problem, tour, 2-opt | 旅行商问题,回路,2-opt |
| genetic algorithm, population, crossover, mutation | 遗传算法,种群,交叉,变异 |
| alpha–beta window [α, β], cutoff, move ordering | α-β窗口 [α, β],剪枝,走法排序 |
| scoring polynomial (Samuel) | 评分多项式(塞缪尔) |
| propositional / first-order logic, entailment | 命题 / 一阶逻辑,蕴涵 |
| clause, literal, resolution, resolvent, refutation | 子句,文字,归结,归结式,反驳 |
| unification, substitution | 合一,代换 |
| set of support, Horn clause, Prolog | 支持集策略,霍恩子句,Prolog |
| satisfiability (SAT), NP-complete | 可满足性(SAT),NP完全 |
| DPLL, unit propagation, branching, backtracking | DPLL,单元传播,分支,回溯 |
| conflict-driven clause learning (CDCL), implication graph | 冲突驱动子句学习(CDCL),蕴含图 |
| first UIP, learned clause, backjumping | 第一唯一蕴含点,学习子句,回跳 |
| phase transition, clause-to-variable ratio | 相变,子句与变量之比 |
| constraint satisfaction problem, domain | 约束满足问题,值域 |
| arc consistency (AC-3), forward checking | 弧相容(AC-3),前向检查 |
| minimum remaining values (MRV), MAC | 最少剩余值(MRV),维持弧相容(MAC) |
| planning, STRIPS, precondition, add list, delete list | 规划,STRIPS,前提条件,添加表,删除表 |
| the frame problem, the Sussman anomaly | 框架问题,萨斯曼异常 |
| relaxed-plan heuristic (h_max, h_FF) | 松弛规划启发式(h_max,h_FF) |
| semantic network, is-a link, inheritance, frame, slot | 语义网络,is-a链接,继承,框架,槽 |
| expert system, rule base, forward chaining | 专家系统,规则库,前向链接 |
| certainty factor | 确定性因子 |
| knowledge engineer, knowledge acquisition bottleneck | 知识工程师,知识获取瓶颈 |
| knowledge graph | 知识图谱 |
| ELIZA, keyword, decomposition, reassembly, the ELIZA effect | ELIZA,关键词,分解规则,重组规则,伊丽莎效应 |
| AI winter, Lighthill report, Lisp machine | AI寒冬,莱特希尔报告,Lisp机 |
| Fifth Generation Computer Systems project | 第五代计算机项目 |
| Moravec's paradox, the long tail | 莫拉维克悖论,长尾 |
| formal verification, SMT, adder, multiplier, miter | 形式化验证,SMT,加法器,乘法器,比较电路(miter) |
| proof assistant (Lean) | 证明助手(Lean) |
| neurosymbolic AI | 神经符号AI |
Names: Alan Turing 图灵; Alonzo Church 丘奇; John McCarthy 麦卡锡; Marvin Minsky 明斯基; Herbert Simon 西蒙; Allen Newell 纽厄尔; Edsger Dijkstra 迪杰斯特拉; Arthur Samuel 塞缪尔; Garry Kasparov 卡斯帕罗夫; Joseph Weizenbaum 魏岑鲍姆; James Lighthill 莱特希尔; Hans Moravec 莫拉维克; Judea Pearl 珀尔; Richard Korf 科尔夫; Alan Robinson 鲁滨逊; Stephen Cook 库克; Leonid Levin 列文. Program names stay in Latin script: Shakey, STRIPS, DENDRAL, MYCIN, XCON, Cyc, ELIZA, DOCTOR, Chinook, Deep Blue → 深蓝, Prolog, Lisp, Z3, Lean, AlphaProof, AlphaGeometry, FunSearch, AlphaEvolve, DeepCubeA.
About this partfrom its README
Part 2 of a thirty-one-part series on how modern AI works and how it came to be (see the series plan
and the syllabus). The symbolic era, 1950 to 1997: what a machine can compute, search and its
heuristics, local search, games, logic and satisfiability, constraints and planning, expert systems, ELIZA, the two
AI winters, and what of it all still runs inside today's systems. Every search, solver and learner in this part runs
on the computer that renders the video (compute.py); numbers about historical systems are the published ones,
cited on screen.
- Forty years to checkmate. Simon & Newell's 1958 forecast of a computer chess champion within ten years, and Deep Blue's 3½–2½ win over Kasparov in May 1997; the era on a timeline, with the two winters; objectives.
- 1. Can machines think? Turing (1936): the machine, a binary incrementer run step by step, universality; the halting problem by diagonalization (derived); Church (1936); Radó's busy beaver (1962): Brady's 4-state champion (107 steps) and Marxen & Buntrock's 5-state champion (47,176,870 steps, 4,098 ones), both run here, proved maximal by bbchallenge in Coq (2024). Turing (1950): the imitation game and his 70% forecast; Jones & Bergen (2025): GPT-4.5 with a persona judged human 73% of the time, ELIZA 23%. The Dartmouth proposal (31 August 1955, quoted); the Logic Theorist (Newell, Shaw & Simon 1956): 38 of the first 52 theorems of Principia's chapter 2; Shrager's 2026 reanimation of the original IPL-V code (16 of 23); the physical symbol system hypothesis (Newell & Simon 1976).
- 2. Search. Search problems; the 8-puzzle's 181,440 states mapped by breadth-first search (the widest ring, the two positions 31 moves away); breadth-first and depth-first, iterative deepening (Korf 1985); uniform-cost search (Dijkstra 1959) as a wavefront on a grid map.
- 3. A*. f = g + h (Hart, Nilsson & Raphael 1968, for Shakey); Dijkstra and A* side by side; every expanded cell checked to lie in the circle of radius C* (Dijkstra) and the ellipse with foci start and goal (A*); optimality from admissibility, and monotone f from consistency, derived; 200 random maps: A*, weighted A* (w = 2, within a factor 2) and greedy best-first, nodes against path cost.
- 4. Where heuristics come from. Relaxed problems (Pearl, early 1980s): Manhattan distance and misplaced tiles from the 8-puzzle's rule; dominance; A* on 100 positions per solution length with h = 0, h₁, h₂, and the effective branching factor; the 15-puzzle with IDA* and an additive 5-5-5 pattern database (Culberson & Schaeffer 1998; Korf & Felner 2002) built here; Korf's optimal Rubik's cube (1997); DeepCubeA's learned heuristic (Agostinelli et al. 2019).
- 5. Climbing and cooling. Hill climbing (schematic landscape); 8 queens from 10,000 random starts (with and without sideways moves; random restarts); the Metropolis rule (1953) and detailed balance to Boltzmann's distribution, derived; simulated annealing (Kirkpatrick, Gelatt & Vecchi 1983) on berlin52 (TSPLIB, optimum 7,542), the tour untangling as it cools; nearest neighbour, 2-opt restarts, annealing and a genetic algorithm (Holland 1975) on an equal cap on actual candidate-cost evaluations, including initialization (not equal CPU time); FunSearch (2023) and AlphaEvolve (2025).
- 6. Games and alpha–beta. Von Neumann's minimax (1928); Shannon's chess paper (1950); tic-tac-toe's whole tree (549,946 positions, 255,168 games); alpha–beta on an illustrative tree with the window [α, β] and pruned branches greyed (McCarthy); the best case b^⌈d/2⌉ + b^⌊d/2⌋ − 1 derived (Knuth & Moore 1975) and checked exactly on uniform trees; Connect Four to depth 9: minimax, alpha–beta in random order, best-looking first, truly best first.
- 7. Machines that learned to play. Samuel (1959): the scoring polynomial, Alpha and Beta, delta; the Nealey game (1962) and the 1966 losses (Schaeffer's account); Samuel's rule as the root of TD learning (Sutton 1988); our own Samuel learner on Connect Four (3 runs, weights replayed, scored against an untrained player and against our hand-set weights, and graded by Part 26's perfect solver); Deep Blue (Campbell, Hoane & Hsu 2002); Chinook (1994) and Checkers Is Solved (Schaeffer et al. 2007).
- 8. Logic and resolution. Truth tables and entailment; first-order logic (Frege 1879), Gödel's completeness (1930), undecidability (Church, Turing 1936); resolution (Robinson 1965): a propositional refutation and a first-order one with unification, built by our prover; saturation against the set of support (Wos, Robinson & Carson 1965) on a family database; Prolog (Colmerauer & Roussel 1972; Kowalski).
- 9. Satisfiability. Cook (1971) and Levin (1973); DPLL (Davis & Putnam 1960; Davis, Logemann & Loveland 1962) on an illustrative formula; the random 3-SAT phase transition for n = 25, 50, 100, 200 (Mitchell, Selman & Levesque 1992), the 4.267 prediction (Mézard, Parisi & Zecchina 2002), proved bounds 3.52 and 4.49; easy–hard–easy cost; CDCL (Marques-Silva & Sakallah 1996; Chaff 2001): an implication graph, first-UIP learning and backjumping; DPLL against CDCL on adder equivalence.
- 10. Constraints and plans. CSPs (Waltz 1975; Mackworth 1977); a Sudoku made here: AC-3 replayed deletion by deletion, and backtracking plain, with forward checking, MRV and MAC; STRIPS (Fikes & Nilsson 1971) and the frame problem (McCarthy & Hayes 1969); the Sussman anomaly (both orders, and the shortest plan); blocks-world state counts (Lah numbers); breadth-first against A* with h_max and greedy search with h_FF (Bonet & Geffner 2001; Hoffmann & Nebel 2001); Graphplan (Blum & Furst), planning as satisfiability (Kautz & Selman 1992).
- 11. Knowledge is power. Semantic networks (Quillian 1968) and frames (Minsky 1974); forward chaining over an illustrative rule base; DENDRAL (1965); MYCIN's certainty factors and its blinded evaluation (Yu et al. 1979); R1 / XCON (McDermott 1980); the knowledge-acquisition bottleneck; Cyc (Lenat 1984); Google's Knowledge Graph (2012).
- 12. ELIZA. Weizenbaum (1966): keywords, decomposition and reassembly; our ELIZA on the user's side of the conversation printed in 1966 (replies compared line by line) and on new lines; the ELIZA effect and Weizenbaum's Computer Power and Human Reason (1976); the original code found (2021) and reanimated (2024).
- 13. The winters. ALPAC (1966); Perceptrons (1969); the Lighthill report and debate (1973); the first winter; the expert-system boom, the Fifth Generation project (1982), Strategic Computing and Alvey (1983); the 1984 AAAI debate; the Lisp-machine collapse (1987); Moravec's paradox (1988); the long tail measured on Part 1's thirty novels and the scoreboard passage.
- 14. What survives. Deep Blue against AlphaZero (Silver et al. 2018); SAT in verification: the Pentium FDIV bug (1994), adders proved equal and a slipped wire caught by our solver, Z3 (2008), a billion SMT queries a day at AWS (Rungta 2022), and the multiplier wall; Lean, AlphaGeometry (2024), AlphaProof (2024; Nature 2025), Gemini Deep Think's IMO gold (2025); PlanBench (Valmeekam et al. 2024) and LLM+P (Liu et al. 2023); neurosymbolic AI.
- Recap, where it comes back (Parts 9, 26, 28, 29, 31), the problem set, Part 3's teaser.
Run from the repo root:
Companion material in this repository
The syllabus's plan for this partfrom SYLLABUS.md, the plan of record
- Turing 1950: the imitation game; Turing machines and what cannot be computed (the halting problem, sketched).
- Dartmouth 1956; the Logic Theorist; the physical-symbol-system hypothesis.
- Search: state spaces; BFS, DFS, uniform cost; A* with admissibility and consistency proved; heuristics from relaxed problems (the 15-puzzle).
- Local search: hill climbing, simulated annealing (Boltzmann acceptance), genetic algorithms.
- Games: minimax; alpha–beta with its b^{d/2} best case derived; Samuel's checkers (1959, the first program that learned); Deep Blue (1997): evaluation functions plus search.
- Logic: propositional and first-order logic; resolution.
- SAT: DPLL and CDCL; the random 3-SAT phase transition at clause ratio ≈ 4.27 (computed).
- Constraint satisfaction: backtracking and arc consistency.
- Planning: STRIPS, the frame problem.
- Knowledge: semantic nets, frames, expert systems (MYCIN, XCON), Cyc; knowledge graphs today.
- ELIZA (1966) and the ELIZA effect.
- The winters: the Lighthill report (1973), the Lisp-machine collapse (1987); Moravec's paradox; why hand-written rules fail on perception's long tail.
- What survives: search inside AlphaZero, SAT/SMT in verification, Lean in AlphaProof, planning in agents; neurosymbolic AI.
Computed: A* vs Dijkstra node counts; alpha–beta vs minimax node counts on Connect Four; the 3-SAT transition sharpening with n; annealing on a TSP. Visuals: the search frontier as a wavefront (Dijkstra's circle vs A*'s ellipse); a game tree with pruned branches greying out; the SAT curve steepening.
中文讲义
本讲的中文部分(与英文版对应)。
习题与解答
1. 曼哈顿距离是一致的。 证明八数码的曼哈顿距离启发式是一致的。
解答
每走一步,只把一个方块滑到相邻的格子,它的行或列变化1,其他方块都不动。所以h恰好变化±1,而这一步的代价是1:对每一步 n → n′ 都有 h(n) ≤ 1 + h(n′),并且在目标处 h = 0。这就是一致性。
2. 一致蕴含可采纳。 证明一致的启发式一定是可采纳的,并举一个可采纳但不一致的启发式。
解答
对从n到目标的最优路径的步数k做归纳。k = 0 时n就是目标,h(n) = 0 = h*(n)。否则设 n → n′ 是最优路径的第一步, 则 h(n) ≤ c(n, n′) + h(n′) ≤ c(n, n′) + h*(n′) = h*(n)。反例:路径 s → a → g,两步代价都是1,取 h(s) = 2,h(a) = 0, h(g) = 0。它从不高估(h*(s) = 2,h*(a) = 1),但 h(s) = 2 > c(s, a) + h(a) = 1。
3. α-β剪枝的最好情况。 若总是先搜索最好的走法,证明α-β在分支数为b、深度为d的均匀树上恰好评估 b^⌈d/2⌉ + b^⌊d/2⌋ − 1 个叶子。
解答
在完美排序下,被搜索的结点分三类(克努特与摩尔)。根是第1类;第1类结点搜索全部子结点,第一个是第1类,其余是第2类; 第2类结点只搜索第一个子结点,它就驳倒了该结点,这个子结点是第3类;第3类结点搜索全部子结点,每个都是第2类。记N₁、N₂、N₃为高度d 处各类结点下的叶子数。则 N₂(d) = N₃(d − 1),N₃(d) = b N₂(d − 1),所以 N₂(d) = b^⌊d/2⌋,N₃(d) = b^⌈d/2⌉;而 N₁(d) = N₁(d − 1) + (b − 1) N₂(d − 1) = N₁(d − 1) + (b − 1) b^⌊(d−1)/2⌋,N₁(0) = 1。分d = 2k和d = 2k + 1两种情况验证, b^⌈d/2⌉ + b^⌊d/2⌋ − 1 满足同样的递推和初值,因此等于N₁(d)。(这两项就是本章的两个证明:你的一步对上对手的每一个应对,你的每一步 对上一个驳斥;它们共享一个叶子。)
4. 模拟退火为什么有效。 证明梅特罗波利斯准则(对称的提议q;能量升高ΔE时以概率e^{−ΔE/T}接受,降低时总接受)对 π(s) ∝ e^{−E(s)/T} 满足细致平衡,并且当T → 0时,分布集中在全局最小值上。
解答
取E(s′) > E(s)。则 P(s → s′) = q e^{−(E(s′) − E(s))/T},P(s′ → s) = q,所以 π(s) P(s → s′) = (q/Z) e^{−E(s′)/T} = π(s′) P(s′ → s);能量相等时显然成立。细致平衡使π成为平稳分布(若走法能连通所有状态, 它就是唯一的平稳分布)。对任一状态s和全局最小值s*,π(s)/π(s*) = e^{−(E(s) − E*)/T},只要E(s) > E*,当T → 0时它趋于0, 所以全部概率最终落在全局最小值上,平均分配。
5. 归结。 证明归结式被它的两个父子句蕴涵,并用归结反驳 {P ∨ Q, ¬P ∨ Q, P ∨ ¬Q, ¬P ∨ ¬Q}。
解答
设某个赋值同时满足 A ∨ x 和 B ∨ ¬x。若x为真,第二个子句迫使B成立;若x为假,第一个迫使A成立;无论哪种,A ∨ B 都成立。 反驳:P ∨ Q 与 ¬P ∨ Q 得 Q;P ∨ ¬Q 与 ¬P ∨ ¬Q 得 ¬Q;Q 与 ¬Q 得空子句。所以这组子句不可满足。
6. 阈值的一个上界。 对有n个变量、m = αn个子句的随机3-SAT,证明满足赋值个数的期望是 2ⁿ (7/8)^{αn},并推出阈值至多为 ln 2 / ln(8/7) ≈ 5.19。
解答
一个固定的赋值只有在三个文字都为假时才违反一个随机子句:八种符号组合里只有一种。各子句独立抽取,所以这个赋值满足全部子句的 概率是 (7/8)^m;对2ⁿ个赋值求和,E[X] = 2ⁿ (7/8)^{αn} = exp(n (ln 2 − α ln(8/7)))。若 α > ln 2 / ln(8/7) ≈ 5.19,它趋于0, 由马尔可夫不等式,P(X ≥ 1) ≤ E[X] → 0:几乎所有公式都不可满足。(这个一阶矩论证只给出上界。解的期望个数很大,并不代表公式可满足的概率很大:大量满足赋值可能集中在一小部分公式里。 4.267附近的值,是统计物理给出的预言。)
Build the film
python -m videos.ai.ai2.compute # the part's numbers, into .cache/ai2
python tools/build.py ai2 # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py ai2 Hook # one chapter, silent, with a contact sheet
Scenes: videos/ai/ai2. Setup: see the course page. Source of these notes: the README and the scenes' narration.