The Claim Contract
Before anything is run, each investigation writes down what it is asking mathematics to establish: the claim in words, how it is read, the exact formal statements, how they relate, what would count as failure, and what the result will not show. Why that file comes first, what is in it, and why it has a hash.
Part I ran eight investigations, and every one started with the same thing: a
file called investigation.json, written before any proof was checked. This
chapter is about that file. It is the most important file in the laboratory,
because it decides what a run is about. Everything else (the kernels, the
computations, the notebook) only reports on it.
Why the contract comes first
A proof assistant answers a precise question: does this proof term have this
type? It does not choose the question. If the question is chosen after the
answer is known, it is easy, and nearly always unintentional, to ask the
question that the proof happens to answer. Chapter 5 — The Wrong Theorem (Part I, Chapter 4) showed the
result: a correct proof of True, credited to the claim “for every natural
number n, 0 + n = n”.
So the laboratory separates the two. The contract is written first and says:
- what the claim is, in words, and where it comes from;
- how we read it;
- the exact formal statements that will stand for it;
- how those statements relate to the claim and to each other;
- what checks will run, and what deliberate mistakes must be refused;
- what a passing run would establish, and what it would not.
The proof files are written separately. A run then asks the kernel whether the proofs establish the statements in the contract, not whatever the proof files happen to state.
A contract, part by part
Here is the Fermat contract from Chapter 2 — One Number Against Fermat (Part I, Chapter 1)
(experiments/investigations/n1-fermat/investigation.json), part by part.
The claim, in words.
"mathematical_statement": "For every natural number n, the number 2^(2^n) + 1 is prime.",
"attribution": "Pierre de Fermat, letter to Frénicle, 1640",
"verdict_under_test": "refuted"
The attribution comes with a source_wording block whose status is
not_yet_transcribed. The contract does not pretend to know Fermat’s exact
words. It records that what we have comes from secondary sources.
How we read it. Three short sentences fix the ambiguities before they can matter: n ranges over 0, 1, 2, …; “prime” has its usual meaning; and the claim is universal, so one composite value refutes it. Chapter 10 — Every, Some, None (Part II, Chapter 1) explained why the last point decides everything.
The propositions. Each is one precise statement, with a role:
| Id | Role | Statement in words |
|---|---|---|
| N1-P01 | refutation | Not every number 2^(2^n) + 1 is prime. |
| N1-P02 | witness | 641 divides 2^(2^5) + 1. |
| N1-P03 | witness | 2^(2^5) + 1 = 641 × 6700417. |
| N1-P04 | witness | 2^(2^5) + 1 = 4294967297. |
| N1-P05 | context | 3, 5, 17, 257 and 65537 are prime. |
| N1-P06 | context | 6700417 is prime. |
| N1-P07 | definition bridge | These are Mathlib’s Fermat numbers. |
Each proposition that a kernel checks carries its statement in that system’s own language, written out in full. For N1-P01:
"lean": {"decl": "fermat_claim_false",
"statement": "¬ ∀ n : ℕ, Nat.Prime (2 ^ (2 ^ n) + 1)"},
"rocq": {"decl": "fermat_claim_false",
"statement": "~ (forall n : nat, prime (2 ^ (2 ^ Z.of_nat n) + 1))"}
These two strings are what the kernels will be asked about. The declaration
name fermat_claim_false only says where to look in the proof file.
Chapter 22 is the reason for that distinction.
The correspondence. The contract says how the formal statements relate to the claim, and to each other:
"claim_to_formal": "N1-C01 is refuted exactly when N1-P01 holds: N1-P01 is
the negation of the mathematical statement, with n over the natural numbers
and 'prime' in its usual sense."
The Lean statement is over ℕ with Mathlib’s Nat.Prime; the Rocq statement is
over ℤ with Rocq’s prime. They are different propositions. The contract does
not hide that. It lists three bridges that connect them: the two
definitions of prime agree on natural numbers, the arithmetic agrees, and the
two divisibility relations agree. Each bridge has the status
stated_not_kernel_checked. They are arguments, written down for a person to
assess.
The checks and controls. Three checks: Lean on formal/lean/FermatEuler.lean,
Rocq on formal/rocq/FermatEuler.v, and an exact computation. Then nine
controls, each a deliberate mistake that must be refused, for example:
{"id": "lean-wrong-index", "kind": "mutation", "system": "lean",
"find": "(h 5).eq_one_or_self_of_dvd", "replace": "(h 4).eq_one_or_self_of_dvd",
"why": "Euler's witness works for n = 5, not n = 4 (65537 is prime)."}
Chapter 23 of this part is about controls. For now, notice that they are written down in advance, with the reason each must fail.
The limits. Every contract ends with two lists. Fermat’s says it establishes that the universal claim is false, checked by two kernels and a computation. It also lists what it does not establish: anything about 2^(2^n) + 1 for n > 5, how Euler found 641, Fermat’s exact wording, and that the Lean and Rocq statements say the same thing. The last item is the correspondence, and the contract leaves it for a person to approve.
The does_not_establish list is not a disclaimer at the bottom of the page.
The notebook prints it on every run, beside the result.
Statements live in the contract, not in the proof
The single most important design choice is where the formal statement lives.
The proof file FermatEuler.lean also states fermat_claim_false. If that
statement were trusted, a proof file could prove something easier under the
same name. So the runner never trusts it. It appends a footer to a copy of the
proof file, in the style of Chapter 15 — What a Formal Proposition Says (Part II, Chapter 6). The footer first defines each
contract statement as a proposition, then binds the declaration to it. From the
recorded run (runs/lean/export.lean):
namespace Inv02FIdentity.Spec
def fermat_claim_false : Prop := ¬ ∀ n : ℕ, Nat.Prime (2 ^ (2 ^ n) + 1)
...
namespace Inv02FIdentity.Bind
theorem fermat_claim_false : Inv02FIdentity.Spec.fermat_claim_false :=
@FermatEuler.fermat_claim_false
The statement in the Spec definition comes from the contract, not from the
proof file. (The Inv02FIdentity names record where this check was first
built: the MATH-INV-02F repair of Chapter 5 — The Wrong Theorem (Part I, Chapter 4).) The kernel accepts the
binding only if the declaration proves exactly that statement, up to
definitional equality. The runner also prints the declaration’s axioms and
refuses any outside the contract’s allowed list. (lean_specs, lean_footer
and judge in src/math_engine/proofs/runner.py; the Rocq side does the
same.)
The wrong-theorem investigation takes this one step further. Its claim lives
in a separate file, claim.json, whose sha256 is written into the
demonstration itself. Change one character of the claim and the demonstration
refuses to run. The runner’s control for it hands over a copy in which
0 + n = n has become n + 0 = n, and checks that the copy is refused.
Why the contract has a hash
A contract can be edited, and sometimes should be. But a result must always say
which version of the contract it is about. So every run records the sha256 of
the investigation.json it used:
Claim contract version 1, sha256 ef384bbfd65f8bdaca0f466cb252a855dc3b9e2578fcb24b83a69eb4d71d0704
Three things depend on that hash.
- Approvals are recorded against it. An approval names the contract hash it approves. Edit the contract and the approval no longer applies, so a run falls back to “pending”. Chapter 24 of this part is about approvals.
- Verification of an old run checks it. `math-engine proof fermat –verify
` reports "the claim contract has changed since this run" if the current contract is not the one the run used. - Revisions stay visible. Gabriel’s contract went from v1 (
8817fd37…) to v2 (9732bda4…) to fix ambiguous wording in the correspondence text. Both runs are kept, each naming its own contract.
What a contract cannot do
A contract cannot make a claim true, and it cannot guarantee that its formal
statements mean what its English says. It makes that question explicit and
gives it an address: the correspondence block, with a status that only a
person can change.
It also cannot stop someone from writing a bad contract. A contract with a
weak statement, a missing control or a vague reading will be faithfully
executed. That is why contracts begin as draft_pending_author_review, and
why Part I prints every contract’s propositions in its chapter where a reader
can check them.
Try it yourself
- Run
math-engine proof --listin the pinned image. For each investigation it prints the contract id and the evidence kind. Which three do not run a proof kernel in a fresh execution, and why? - Open
experiments/investigations/n1-fermat/investigation.jsonand find the propositions with no Rocq statement. Why does the correspondence list them assingle_kernel? - Copy the repository, change the
+ 1in N1-P01’s Lean statement to+ 3, and runmath-engine proof fermat. What does the Lean check report, and what status does the run end with? - With the contract still edited, run
--verifyon the approved run inn1-fermat/kernel-runs/2026-11-13-approved/. What does it report, and why is that correct? - Read the wrong theorem’s
controls/claim-tampered.json. What exactly was changed? Why must the demonstration refuse to run at all, rather than run its gates against the changed claim?
Worked answers: Chapter 35 — Appendix A: Solutions to the Exercises (Part IV, Appendix A)#chapter-1-the-claim-contract.
What this chapter does not claim
The contract format is the project’s own. It is not a standard, and other laboratories make other choices: AlphaProof Code’s locked specification, for instance, plays a similar role at a much larger scale (chapter 27 of this part). A contract is a proposal about how to read a claim, not a guarantee that the reading is right.
Evidence record
| Contracts | experiments/investigations/{n1-fermat,n2-abel-f1,p03-haraux,p04-wrong-theorem,n3-grasshopper,p06-kempe,p07-simpson,p08-gabriel}/investigation.json |
| Loading and validation | load_investigation in src/math_engine/proofs/runner.py |
| Statement binding | lean_specs, lean_footer, rocq_specs, rocq_binding_text, judge (same file); src/math_engine/formal_identity.py |
| Contract hash in use | Fermat approved run 20261113T161233Z-9c5ae090, contract sha256 ef384bbf… |
| Pinned claim | p04-wrong-theorem/claim.json (sha256 37b8db8f…) and its tampered-copy control |
Further Reading
For deeper study; not sources for the chapter’s claims.
- C. A. R. Hoare. “An axiomatic basis for computer programming.” Communications of the ACM 12(10) (1969), 576–580. DOI. Why read it: The foundational paper on specifying programs by preconditions and postconditions, the intellectual ancestor of writing the claim before the proof.
- Bertrand Meyer. “Applying ‘design by contract’.” Computer 25(10) (1992), 40–51. DOI. Why read it: The classic exposition of contracts as explicit obligations and guarantees, useful for seeing what a claim contract does and does not settle.
- Jim Woodcock, Peter Gorm Larsen, Juan Bicarregui, John Fitzgerald. “Formal methods: practice and experience.” ACM Computing Surveys 41(4) (2009), 1–36. DOI. Why read it: A broad survey of formal methods in practice, useful for situating the book’s contract format among other ways of making specifications explicit.
Next in Part III: Chapter 21, how one command turns a contract into a reproducible record.