What it costs

A kept table narrows the tail, not the gap

A certificate by deepening throws its table away at every iteration, and the obvious repair is to keep what earlier iterations proved exactly. On a thousand deep positions of 4 × 5 Domineering it helps: plain deepening's mean cost falls by a fifteenth, and the one-sided window's worst case by two-fifths once its guesses are kept as well. It does not cross the search that finishes at any budget, on any of three boards — and a plain certificate cannot reuse a single guess, because a position one move further from the cut is a different question.
14 min read 6 figures What a search costsIt has to end

Assumes: A proof inside a budget · Where a search may stop

A proof inside a budget put the certificate built over the essays before it to the only test that matters for it. Deepening to agreement — search one move deeper at a time, guess at the cut that the player with a move wins, stop when two consecutive depths agree — is a proof that arrives early on some positions. The fair question is how many proofs arrive inside a cap on positions expanded, and on a thousand deep positions of 4 × 5 Domineering the memoised search that simply finishes had proved more at every cap from sixteen to eight thousand.

It put the blame on one design choice and named the repair:

Every certificate here starts each iteration from nothing … The obvious repair is a certificate that keeps what earlier iterations proved: a position whose verdict one iteration established exactly, because its lines ended before the cut, need never be searched again.

The repair works, in a measured and limited way. It does not change the order.

A kept table lifts the curve and does not cross it. For 1000 deep positions of 4 × 5 Domineering, the number each method has proved within budgets from 16 to 8,192 positions expanded. At 128: finishing 991, the window keeping every verdict 884, the window with fresh tables 861, plain deepening keeping exact verdicts 564, plain deepening fresh 478.
Fig. 1 Proved verdicts against a budget of positions expanded, for a thousand deep positions of 4 × 5 Domineering. Keeping the table lifts both certificates in the middle budgets — plain deepening at 128 positions, the one-sided window at 128 and 256 — and neither reaches the search that finishes at any budget.

What an exact verdict is

An iteration of the certificate at depth d searches to d moves and then guesses. Most of what it computes depends on the guess, and is useless to the next iteration, which will search one move further and guess somewhere else. But not all of it. A position from which every line ends before the cut — the board fills, a player has no placement — is solved outright, and the verdict holds at every depth.

So a verdict is exact when no guess was consulted beneath it. The rule propagates up the tree the way a who-wins answer does. A position with no moves is an exact loss for the player to move. A position won through a reply that is an exact loss for the opponent is an exact win, whatever else was guessed among the moves not tried. A position lost because every reply wins for the opponent is an exact loss only if every one of those replies was exact. A single guessed reply makes the loss a guess.

A kept table holds the exact verdicts in one store for the whole deepening, keyed by position alone, consulted before anything is expanded. That is the first variant measured. The second keeps the guessed verdicts as well, in the iteration’s own table keyed by position and depth left, and carries that table forward instead of emptying it. This is sound, because an iteration that meets a position with the same depth left asks exactly the question the earlier one answered; but the iteration that uses an old guess has, like the old one, relied on a guess, and its stopping rule must be told so. The first run of this measurement left that out and returned a wrong proved verdict, which is the reason every verdict here is checked against the board’s own answer.

What the kept table saves

What a kept table saves. Positions expanded to a proof at five points of the distribution, for the finishing search and six certificates. Finishing: median 36, worst 513. Plain deepening: median 135 fresh and 121 keeping exact verdicts. One-sided window: median 38 in every variant, worst 1825, 1422 and 1079.
Fig. 2 Positions expanded to a proved verdict, at five points of the distribution, for the finishing search and six certificates — plain deepening and the one-sided window, each with fresh tables, keeping exact verdicts, and keeping every verdict. The kept tables cut the tail; the medians barely move.

For plain deepening, keeping exact verdicts cuts the mean cost of a proof from 161 positions to 150, and the median from 135 to 121. The nine-tenths point falls from 299 to 281, and the worst position from 1,590 to 1,440. That is a fifteenth of the cost, and the finishing search’s median is 36. Keeping the guesses as well changes nothing at all: the two kept variants return the same cost on every one of the thousand positions.

For the one-sided window — the certificate that declines to guess where the player to move is level or behind on placements, and searches on two moves there — the median stays at 38 in every variant, two above the finishing search’s 36. The tail is where the table pays. Keeping exact verdicts brings the nine-tenths point from 184 to 160 and the worst case from 1,825 to 1,422; keeping everything brings them to 143 and 1,079. The mean falls from 69 to 59. The finishing search’s mean is 41, its nine-tenths point 74, its worst 513.

So the repair does what a repair to a tail should: the expensive positions get cheaper, by up to two-fifths, and the cheap ones stay as they were. It closes about a third of the distance between the window and the finishing search, measured by the mean, and none of the distance at the median.

Why plain deepening cannot use an old guess

The striking line in that table is that keeping guesses buys plain deepening nothing at all. The reason is in the key.

Exact verdicts carry, guesses only through the window. For the certificates that keep a table, the mean iterations per position and the mean lookups answered by an earlier iteration. Plain deepening keeping every verdict answers 12.2 lookups from exact verdicts and none from old guesses; the window keeping every verdict answers 8.3 and 4.0.
Fig. 3 For the certificates that keep a table, the mean number of iterations per position and the lookups answered from what an earlier iteration left: its exact verdicts, and its depth-keyed guesses. Plain deepening answers about twelve lookups a position from exact verdicts and none from old guesses; the window answers about eight and four.

Plain deepening’s iteration d reaches a position along some line of k moves and asks about it with d − k moves left. The next iteration reaches the same position along the same line and asks with d + 1 − k left. The key has changed. Every position reached by the same route is one move further from the cut each time, so a guess made at depth left two is never asked for again at depth left two by the same route; it can be met again only through a transposition that reaches the position by a line one move longer, and on these positions that never happens. On the thousand deep positions, plain deepening with a kept guess table answers exactly zero lookups from an earlier iteration’s guesses.

What it can reuse is exact verdicts, keyed by position alone: about twelve lookups a position, across a mean of six and a half iterations. Those are the end positions and the near-ends that one iteration solved and the next would otherwise have walked again, and they are the fifteenth.

The window is different because of how it searches on. Where it declines to guess it continues two moves at a time, and the depths it continues through are folded into two keys — an even and an odd number of moves past the cut — rather than counted separately. So a position examined past the cut in one iteration is examined under the same key in the next, and the window answers about four lookups a position from old guesses, on top of eight from exact verdicts. That is the whole of the difference between its two kept variants, and the reason its tail shrinks twice.

A different question at every depth found the same thing on Sylver Coinage and named it in its title: an iteration of a deepening search asks a different question of every position than the iteration before, so its answers cannot be reused except where the answer does not depend on the question. Exact verdicts are those answers. The finding here is that on Domineering they are a small share of the work.

Position by position

Cheaper on a few more positions. Per position, how often each certificate costs less than, the same as, or more than the finishing search on the thousand deep positions of 4 × 5. The window is cheaper on 20 with fresh tables and 46 keeping every verdict; plain deepening on none.
Fig. 4 For each certificate, on how many of the thousand deep positions its full cost is below, equal to or above the finishing search’s, and the most positions it proves that finishing has not at any budget. Keeping exact verdicts takes the window from 20 cheaper positions to 46; plain deepening is cheaper on none.

Plain deepening is cheaper than finishing on none of the thousand positions, fresh or kept. The window with fresh tables is cheaper on 20, which is the count the earlier essay found. Keeping exact verdicts takes that to 46, and keeping everything leaves it at 46. Ties — positions where the window happens to expand exactly what finishing does — stay near 280, because there the window searches on from the start and behaves as the finishing search does.

And the budget question has the same answer as before. The most positions any certificate proves within a budget that the finishing search, given the same budget, has not proved is three, at a budget of 32, for every window variant; at 64 it is one with fresh tables and two with a kept table. Those are the only budgets at which any certificate proves anything first, and the kept table adds a single position to the count. A program that switched from the fresh window to the kept one would, over a thousand deep positions and ten budgets, gain one proof that finishing would not have had in time. The kept table makes the window’s proofs arrive sooner on positions that finishing had already proved sooner still.

The openings

The deep sample is drawn from positions with six or more moves left, which is where a larger board’s search is spent. The thirty-three positions of 4 × 5 with eight or nine moves left — the empty board among them — are the hardest test.

On the openings, still behind. The 33 openings of 4 × 5 Domineering, proved within budgets from 128 to 2,048 by the finishing search and the six certificates. Finishing proves 17 within 128; the window keeping every verdict 10.
Fig. 5 The 33 openings of 4 × 5 Domineering, proved within budgets from 128 to 2,048 positions by the finishing search and the six certificates, with each method’s worst case. Keeping every verdict brings the window’s worst opening from 2,040 positions to 1,273, still above finishing’s 891.

The finishing search proves seventeen openings within 128 positions, twenty-two within 256 and all thirty-three by 1,024. The window keeping everything proves ten, twenty-one and twenty-eight at the same budgets — one more at 1,024 than the window with fresh tables — and all by 2,048. Plain deepening proves none by 256 with or without a kept table, and its kept variant is a single position ahead of fresh at 512 and two at 1,024.

On the openings the kept table helps most in absolute terms — the window’s mean cost there falls from 444 positions to 347, plain deepening’s from 900 to 832 — and least in effect on the budget curve, because the openings are expensive for every method and a cut of a fifth leaves an expensive method expensive. The openings are where a budget runs out, and they are where the gap stays widest.

Three boards

Three boards, the same gap narrowed. 4 × 4: finishing 23.9, window fresh 60.7, keeping all 46.8; 3 × 6: finishing 31.3, window fresh 45.0, keeping all 37.7; 4 × 5: finishing 40.9, window fresh 69.3, keeping all 59.1.
Fig. 6 Mean positions expanded to a proof on the deep positions of 4 × 4, 3 × 6 and 4 × 5, for the finishing search and the one-sided window with fresh tables and keeping every verdict, with the nine-tenths points of the kept window and of finishing. The kept table closes a third to a half of the gap and never all of it.

On 4 × 4 the window’s mean falls from 60.7 to 46.8 against finishing’s 23.9; on 3 × 6 from 45.0 to 37.7 against 31.3; on 4 × 5 from 69.3 to 59.1 against 40.9. That is 38, 53 and 36 per cent of the distance closed. The nine-tenths points tell the same story with more emphasis: the kept window’s ninetieth-percentile position costs 84, 74 and 143 on the three boards, against finishing’s 36, 62 and 74.

Nothing about the pattern changes with the board. The kept table is worth something on every one, and the order — finishing, then the kept window, then the fresh window, then plain deepening a long way behind — is the same on every one.

Why the gap that remains is structural

The finishing search keys its table by position alone. The kept certificate keys its exact verdicts by position alone too, which is why it closes part of the gap, but everything it has not solved outright it keys by position and depth left — and on a deep position almost nothing is solved outright until late. The tree and the graph is the whole explanation at the scale of one search: Domineering’s positions are reached by many routes, a table keyed by position collapses those routes into one visit, and any key that also records how far the search has to go splits them again.

A certificate needs the depth in its key, because the depth is what its guesses depend on, and its proof rests on comparing two guesses made at consecutive depths. So the part of the graph the finishing search visits once, the certificate visits once per depth at which its answer was a guess. Keeping the exact verdicts removes the part where the answer was never a guess. What remains is the price of having guessed, and no table can refund it.

A strategy is not a certificate found the same economics in Nim on a much larger scale, and space is the resource states the other half of the ledger: a kept table costs memory that a fresh one does not, so a program bounded by memory rather than by positions expanded would weigh the variants differently. The kept exact table here holds a few hundred positions per proof; the finishing search’s table holds everything it visited.

How each proof was run

Every position in the sample is proved seven times. The finishing search runs once, with a table keyed by position. Each certificate runs iterations of depth nought, one, two and onward. At every node it first looks in the kept exact table, if it has one; then in the iteration’s table under the key of position and depth left; and only then expands the position, counting one. At the cut it guesses that the player to move wins if that player has any placement left, or — for the window — declines to guess where the player is level or behind and searches on. It stops when two consecutive iterations agree, or when an iteration consulted no guess at all, or when the root is answered from the exact table, which is a proof of its own.

The fresh-table variants are the certificates of the essay this continues, unchanged, and reproduce its counts. The kept variants differ only in which tables survive from one iteration to the next. So every difference in the figures is the table, and nothing else.

What a program would do with this

For a program that wants proofs on a board too large to finish, the measurement is a recommendation with a ceiling. Keep the exact verdicts: they are free to recognise, cost little memory, and never make a proof wrong. Keep the guess table too if the certificate folds depths, as the window does; it is worthless otherwise. Expect the tail to shrink and the median not to move.

And do not expect to overtake a search that finishes. On every board here, at every budget, the finishing search proved at least as many positions as the best kept certificate. The certificate remains what a proof inside a budget concluded it was — a label that deepening’s interim guesses earn on a few positions for free — and a kept table makes the label a little cheaper to earn, not a reason to deepen.

The convention named

Domineering, normal play, Left placing vertical dominoes. A position’s verdict is whether the player to move wins. Moves are tried in the order that leaves the opponent fewest replies, for every method. A budget is a cap on positions expanded, summed over every iteration of a certificate; a table hit costs nothing, whether in the iteration’s own table, a carried guess table or the kept exact table. Deep positions are those whose longest line left is six moves or more, sampled with the same seed as the essay this continues, so the fresh-table rows reproduce its numbers exactly — median 135 for plain deepening, 38 for the window, 36 for finishing.

What three small boards cannot say

Large boards. A deep position here has a longest line of six to nine moves; on a large board it may have forty, and the exact verdicts — positions solved to the end — would be a vanishing share of a search that never reaches the end. If anything, that makes the kept exact table worth less there, not more, while the window’s carried guesses, which do not depend on reaching the end, might be worth more. Nothing here measures it.

Other orders and other windows. Every method uses the fewest-replies order and the one-sided window that suits the guess. A window that declined to guess more often would fold more depths together and carry more guesses — and turn, by the argument of search on in pairs of moves, more nearly into the finishing search.

Memory as the budget. The finishing search keeps everything it visits and the kept certificate keeps much less; capped on memory instead of positions, the comparison could reverse.

Still open: whether depth can leave the key

The gap that remains is the depth in the certificate’s key, and the window shows that folding depths together is what lets guesses be reused. That suggests the last version of the certificate worth measuring: one whose guess at the cut does not depend on the depth at all, so that a single table keyed by position serves every iteration. A guess of that kind is a heuristic value rather than a who-moves-last rule — the difference in remaining placements, say, which a verdict that changes with the depth found right on nearly three-quarters of positions at depth nought. The bracket that makes two agreeing depths a proof would have to be re-established for such a guess, and whether it can be is the question; if it can, the certificate’s table becomes the finishing search’s table, and the remaining difference between a proof that arrives early and an answer that arrives at the end would be the cost of the guess alone.

Part 7 of 7

One argument about Search. The parts either side of it:

The objects named here

The third axis, after the field and the series: the games, values and theorems themselves, and every essay that touches each one.

CertificateDomineeringExhaustive searchHorizon effectMemoisationMove orderingProofSearchSearch costTransposition table