taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Volume P0 · Guide

The table of black boxes and the table of errata

Draft. This chapter is written and checked by the tools of the project, and a person has not reviewed it yet. Read it with care.

Contents
  1. What a black box is
  2. The table of black boxes
  3. The first expected rows
  4. The table of errata
  5. How the tables are made

What a black box is

A black box is a result that the handbook uses without proof. The handbook states it, cites a source, and applies it. It does not prove it, because the proof needs more than the volume can teach, or because the proof would take many pages that teach little about algorithms.

Each black box has two sides. In the handbook, it is a row of the table of black boxes (spec 11.3). In Lean, it is a named hypothesis in TAOCP/Library/Hypotheses.lean (Section 4.6). A result that rests on it has the status proved-mod, and its page names the black box.

Why the handbook uses few of them

A black box is a debt. A reader must trust it, and the Lean proofs that use it are not complete. So the handbook uses a black box only when all of these hold:

  1. The result is published, with a proof that experts accept.
  2. The proof is outside the scope of the volume that uses it.
  3. Mathlib does not have the result yet, in a form that the project can use.
  4. The handbook states the result exactly, with all its conditions, so that a reader can check each use.

The handbook never uses a black box to skip a proof that it can give. A result that the prerequisite volumes prove is not a black box, even if its proof is long.

Example. Stirling's formula, n!∼2πn (n/e)nn! \sim \sqrt{2\pi n}\,(n/e)^n, is used all over TAOCP. It is not a black box. P5 proves it, and Mathlib has it: the theorem Stirling.tendsto_stirlingSeq_sqrt_pi says that n!/(2n (n/e)n)n!/(\sqrt{2n}\,(n/e)^n) tends to π\sqrt{\pi}.

Example. The Euler-Maclaurin formula with an explicit remainder gives, among much else, Hn=ln⁡n+γ+12n−112n2+ϵnH_n = \ln n + \gamma + \frac{1}{2n} - \frac{1}{12n^2} + \epsilon_n with 0<ϵn<1120n40 < \epsilon_n < \frac{1}{120n^4}. For n=10n = 10, the four main terms give 2.9289674, while H10=2.9289683H_{10} = 2.9289683. The difference is 8.29×10−78.29 \times 10^{-7}, just below 1120⋅104=8.33×10−7\frac{1}{120 \cdot 10^4} = 8.33 \times 10^{-7}. P5 proves the formula in the handbook. But Mathlib has no Euler-Maclaurin formula at the time of writing. So the Lean side may need it as a named hypothesis until somebody proves it in Lean. Then it is a black box for Lean, not for the reader.

Black boxes and trust

A black box does not make a result false. It makes it conditional. The page of each proved-mod node prints the hypotheses under the result with their sources (spec 14.3). A reader who accepts the published proof of the hypothesis can accept the result. A reader who does not can see exactly what is missing.

Example. Suppose that a theorem about the average depth of a trie uses a black box from the analysis of Mellin transforms. The page of the theorem says: "proved under one named hypothesis", then the hypothesis in words, its source, and a link to its row in the table. The page never says just "proved".

The table of black boxes

The table has one row for each black box. It is in this chapter of each release, and on the site at /learn/blackboxes/.

The columns

Column Content
Result the statement in the handbook's own words, with all its conditions
Source the published proof: authors, title, year, and the theorem number
Used by the volumes and sections of the handbook that use it, and the number of nodes of the map that rest on it
Lean the name of the named hypothesis, such as TAOCP.Hyp.transfer
State open, or proved in Lean (with the date), or in Mathlib (with the name)

A row leaves the table when its result is proved in Lean. The release notes say when a row left, and every node that rested on it moves from proved-mod to proved at the next index.

At milestone S1 the table has no rows. The example row below is invented to show the form.

Result Source Used by Lean State
(invented) If a generating function has a single dominant singularity of a given algebraic type, its coefficients have the matching asymptotic form. Flajolet and Odlyzko, "Singularity analysis of generating functions", 1990 P5 Ch. 8; C5 Section 5.2.2 (invented) TAOCP.Hyp.transfer (invented) open

Example. The coefficients of (1−4z)−1/2(1 - 4z)^{-1/2} are the central binomial coefficients (2nn)\binom{2n}{n}. The transfer theorem gives (2nn)∼4n/πn\binom{2n}{n} \sim 4^n/\sqrt{\pi n}. For n=10n = 10, (2010)=184,756\binom{20}{10} = 184{,}756 and 410/10π≈187,0794^{10}/\sqrt{10\pi} \approx 187{,}079. The ratio is 0.987580.98758, close to 1−18n=0.98751 - \frac{1}{8n} = 0.9875, which is the next term of the expansion. This special case follows from Stirling's formula and needs no black box. The general theorem covers functions where no such direct route exists.

Example. Read the column "Used by" before you start a chapter. If a chapter of a companion volume uses three black boxes, you know in advance which of its results are conditional. The page of each section of the handbook also names the black boxes that it uses.

How to read a row

  1. Read the result and its conditions. A black box applies only when all its conditions hold. Most errors with black boxes come from a missed condition.
  2. Look at the source. The handbook gives the theorem number, so you can find the proof.
  3. Look at the Lean name. Its docstring has the same statement in Lean. If the Lean statement and the words differ, that is an error to report (Section 3.6).

The first expected rows

The first black boxes are expected in the analysis of algorithms, in the HM exercises and in P5 (spec 09.2 and 11.3). There, TAOCP uses results of complex analysis that Mathlib does not have yet. This section lists the candidates. None of them is a row yet. Each one becomes a row only when a section of the handbook or a node of the map needs it and the conditions of Section 6.1 hold.

Candidate What it gives Where TAOCP needs it
Euler-Maclaurin summation with an explicit remainder asymptotic series for sums such as HnH_n and ln⁡n!\ln n!, with error bounds Volume 1, Section 1.2.11, and many analyses after it
transfer theorems of singularity analysis the growth of the coefficients of a generating function from its behaviour near its nearest singularity the analysis of trees, of sorting and of searching
the saddle point method in a general form the growth of coefficients when the generating function has no singularity in the finite plane, as for eze^z the counts of permutations and of set partitions
asymptotics of harmonic sums by Mellin transforms the main terms and the small oscillating terms of sums such as ∑k(1−(1−2−k)n)\sum_k (1 - (1 - 2^{-k})^n) the analysis of tries and of digital search in Volume 3

Mathlib grows every month. Before a candidate becomes a row, the project checks whether Mathlib has it by then. A candidate that Mathlib has is not a black box.

Example. The first row of the list comes first for a reason. Section 1.2.11 uses Euler-Maclaurin summation to get the expansion of HnH_n. With the four terms of Section 6.1, the expansion gives H100≈5.18737751756H_{100} \approx 5.18737751756, and the true value is 5.187377517645.18737751764. The error is less than 10−1010^{-10}, as the bound 1120⋅1004≈8.3×10−11\frac{1}{120 \cdot 100^4} \approx 8.3 \times 10^{-11} says.

Example. Toss a fair coin until the first head, and count the tails before it. Do this nn times, independently, and take the largest of the nn counts. Its mean is ∑k≥1(1−(1−2−k)n)\sum_{k \ge 1} \bigl(1 - (1 - 2^{-k})^n\bigr), because the largest count is at least kk with probability 1−(1−2−k)n1 - (1 - 2^{-k})^n. Sums of this form are typical of the analysis of tries. The main terms are log⁡2n+γ/ln⁡2−12\log_2 n + \gamma/\ln 2 - \frac12, but the rest does not tend to 0: it is a small periodic function of log⁡2n\log_2 n, with an amplitude of about 1.6×10−61.6 \times 10^{-6}. The Mellin method explains that part. A proof of such a term in Lean needs the method in a general form. That is the kind of result that may enter as a named hypothesis.

What the black boxes are not

The table is not a list of hard proofs that the project has not done. A result of TAOCP that is not yet proved is a node with the status stated, not a black box. A black box is always a result from outside TAOCP, with a published proof, that a node of TAOCP uses.

The table of errata

TAOCP is checked with great care, and Knuth fixes it in every printing. But the project checks about 5,360 answers in Lean, and a check of that size finds some errors that nobody saw before. The table of errata lists them, with the state of each one (spec 14.4).

The states

Each possible error of the book goes through these states. The ledger of the project, errata/ledger.yaml in tamnd/taocp, has one entry for each.

State Meaning
candidate a check found a disagreement between the book and the project, for example in check F3
known the error is already in Knuth's published errata; the node uses the corrected statement
confirmed Lean proves that the printed claim is false, and two people of the project have read the case
sent the confirmed error was sent to Knuth in a batch
posted Knuth has posted the correction

A candidate is not an error yet. Most candidates come from a mistake in a Lean statement, not in the book. That is why a candidate needs a Lean proof and two readers before it is confirmed.

Example. Check F3 finds that the answer of a node differs from the answer in the book. The node gets the flag erratum-candidate. A person first compares the statement with the book again. Suppose that the statement had used Finset.range n where the book sums from 1 to nn. Then the error is in the statement. The statement is fixed, and the candidate is closed. The book was right.

Example. Suppose instead that the statement is right, and that Lean proves that the printed formula gives 13 for n=4n = 4, while the true count is 14. Then a check of Knuth's errata files comes next. If the fix is already there, the state is "known". If not, and two people have read the case, the state is "confirmed". These numbers are invented, as an illustration.

The rule of disclosure

Knuth receives far more mail than he can read. On 2026-11-25 he started a moratorium: reports sent after that date will not be read until he posts updated errata. The project respects this. It sends nothing while the moratorium lasts. When Knuth says that reports are welcome again for a volume, the owner of the project sends one batch for that volume, in the form that Knuth asks for.

The table on the site and in the handbook follows a rule of disclosure. An erratum is listed in full only after one of two events, whichever comes first:

  1. it was sent to Knuth, and 90 days have passed;
  2. Knuth has posted it.

Until then, the node shows only that a candidate is being checked, with no details. The table shows the count of items in each state, but not the items.

Example. Suppose that a batch is sent on 2027-03-01 (an invented date). Its errata can be listed in full from 2027-05-30, which is 90 days later. If Knuth posts one of them on 2027-04-15, that one can be listed from 2027-04-15.

Example. A listed erratum uses neutral words: what is printed, what Lean proves, and the smallest case. For instance: "the printed answer gives 13 for n=4n = 4; the brute-force count is 14; the Lean proof of the corrected formula is linked here." It never comments on the author.

Two more rules

Knuth asked readers to confirm about 35 specific exercises, from MPR-28 in Volume 4B to exercises of Section 7.2.2.3 in Volume 4 Fascicle 7. For these, the owner follows the instructions on Knuth's news page at the time, and nothing else.

The project does not ask for Knuth's reward checks. If he sends them, they go to the owner. At milestone S1, the ledger has no entries.

How the tables are made

Nobody writes the rows of the two tables by hand. Each table comes from records, and the records come from the Lean files and the ledger. This section gives the sources and says how a reader checks that a table is current.

The sources

Table Comes from
black boxes the named hypotheses in TAOCP/Library/Hypotheses.lean, with their docstrings; the nodes of the map that use each one; the sections of the handbook that cite each one
errata the ledger errata/ledger.yaml of tamnd/taocp, with only the details that the rule of disclosure allows

At each release, the builder of the handbook, thb, reads these sources and writes both tables, with the edition of the map that it used. The same records feed the pages /learn/blackboxes/ and /errata/ of the site.

At release v0.0.1, both sources are empty: the Lean code has no file TAOCP/Library/Hypotheses.lean yet, and the ledger has no entries. And thb does not yet write the tables. This section describes the plan of the spec (11.6). The release notes will say when the builder starts to write them.

Example. Suppose that a new node in Volume 3 uses the named hypothesis TAOCP.Hyp.transfer (an invented name). At the next index, the map gets a new edge from the node to the hypothesis, and the count in the column "Used by" of its row goes up by one. Nobody edits the table.

Example. Suppose that the owner sends a batch with three confirmed errata on a given day. The ledger records the date. 90 days later, the next build of the site lists the three errata in full, and the next release of the handbook does the same. Before that, both show three items in the state "sent", with no details.

Checking that a table is current

Each table gives the edition of the map that it was built from: a short commit hash of tamnd/taocp, such as c97f505, and a date. To check a table:

  1. Compare its edition with the edition on the site. If the site is newer, the site is the current source.
  2. For the black boxes, open TAOCP/Library/Hypotheses.lean at the pinned commit of tamnd/taocp-lean, and count the hypotheses. The count must match the rows.
  3. For the errata, open errata/ledger.yaml and count the entries in each state. The counts must match the table.

If a count does not match, report it (Section 3.6). A table that does not match its records is an error of the builder.

Example. Release v0.0.1 of the handbook was built from the map at edition c97f505 and the Lean code at 68ab364. The table of black boxes has no rows. A reader looks for the file of hypotheses at the Lean commit and finds that it does not exist yet. The counts match, so the table is current for that edition.

Example. A reader finds one hypothesis in the Lean file, but the table of the handbook release has no row. The reader checks the dates. The hypothesis was added after the release, so the release is old, not wrong. The site, built later, shows the row.

Things to try

  1. Choose one result that P2 proves and that TAOCP uses often. Explain in one sentence why it is not a black box (Section 6.1).
  2. Compute H20H_{20} and the four-term expansion of Section 6.1 for n=20n = 20. Check that the difference is below 1120n4\frac{1}{120n^4}. P5 teaches Euler-Maclaurin summation.
  3. Compute (2nn)\binom{2n}{n} and 4n/πn4^n/\sqrt{\pi n} for n=5n = 5 and n=20n = 20, and their ratio. Compare the ratio with 1−18n1 - \frac{1}{8n}. P3 teaches the generating function (1−4z)−1/2(1 - 4z)^{-1/2}.
  4. An erratum was sent on 2027-01-10 and Knuth has not posted it. From which date can the site list it in full? (Section 6.4.)
  5. Say which state an item of the ledger has when its fix is already in Knuth's errata files (Section 6.4).
  6. Name the two files that you would open to check that a table of a release is current (Section 6.5).

This chapter describes two tables that come with each release of the handbook. The table of black boxes lists the results that the handbook uses without proof. The table of errata lists the errors in TAOCP that the project has found, with the state of each one. Both tables are part of the learner kit (spec 11.6, items 2 and 7).

Section 6.1 explains what a black box is and why there are few of them. Section 6.2 describes the table of black boxes. Section 6.3 lists the first rows that the project expects. Section 6.4 describes the table of errata and the rule that decides when an erratum becomes public. Section 6.5 says how both tables are made and how a reader checks that a table is current.

At milestone S1 both tables are empty. The examples use invented rows, and each example says so.

The source of this page. Something is wrong? Report it.