Environment Building

Mathematics Laboratory

The capstone of Adversarial Mathematics: From First Principles is a working mathematics laboratory: one proof runner, several methods of checking, and notebooks that let readers inspect what was established and what remains an interpretation.

A place to test a mathematical claim

A calculation returns the expected answer. A proof file compiles. An AI assistant announces that a theorem has been proved. Which of those events actually establishes the claim you started with?

They can mean different things. A computation may cover only the examples it was given. A formal proof may depend on an axiom or an unfinished obligation. A kernel may correctly accept a theorem whose statement is weaker than the problem you intended to solve. A historical example may depend on a diagram or interpretation that has not been independently established.

Mathematics Laboratory is the practical result of Adversarial Mathematics: From First Principles. It gives a reader a way to state a claim, run the checks that apply, deliberately challenge them, and open a notebook showing what happened. It is a local, reproducible environment rather than a hosted proof service.

Read the book · Inspect the implementation

The outcome to aim for

A useful investigation should leave you able to answer:

  • What exact statement were we trying to establish, and under which assumptions?
  • What proposition did the proof checker actually accept?
  • Did Lean or Rocq run now, or is the result a verified historical record?
  • What was computed independently, and what does that computation cover?
  • Which deliberately incorrect changes were rejected, and why?
  • Can another reader verify the evidence files without trusting a prose summary?
  • What still depends on source fidelity, mathematical interpretation or a human decision?

The practical deliverable is an evidence-bound notebook, not a green checkmark. A notebook contains the claim, the checks performed, the observed results, relevant identities and limitations, with a corresponding machine-readable record and hashes. Notebooks are generated from the run evidence; they are not a substitute for it.

The investigation loop

Question from the book or reader
              |
       Explicit claim contract
              |
   Formal proof / exact computation
              |
    Deliberately failing controls
              |
       Execution and evidence
              |
     Notebook + SHA-256 record
              |
   Examine statement correspondence
              |
   Human judgment where required

The runner is the common interface. It does not turn every method into the same kind of proof. A fresh Lean kernel check, a Python graph computation and a verification of archived kernel output retain different evidentiary meanings.

Start with one counterexample

Fermat conjectured that every number of the form \(2^{2^n}+1\) is prime. The first cases looked convincing. Euler’s counterexample is decisive:

\[ 2^{32}+1=4,294,967,297=641\times6,700,417. \]

One composite number defeats a universal claim. In the laboratory, the Fermat investigation pairs that mathematical argument with formal statements, computations and failure controls. It also records whether the checked formal statements correspond to the claim presented in the book.

With the repository checked out and the pinned math-env Docker image available, run from the repository root in PowerShell:

$img = docker image inspect math-env --format '{{.Id}}'
New-Item -ItemType Directory -Force out | Out-Null

docker run --rm --network none `
  -e UV_OFFLINE=1 `
  -e MATHENV_IMAGE_ID=$img `
  -v "${PWD}:/source:ro" `
  -v "${PWD}/out:/out" `
  math-env uv run --offline math-engine proof fermat `
    --out /out/proof-fermat

Inspect out/proof-fermat/notebook.md, notebook.ipynb and result.json. The run directory also contains integrity information, including SHA256SUMS. The Docker command assumes you already have the repository and its pinned image; building or obtaining that image is documented in Part IV of the book.

You can also follow the book using its filed notebooks without running Docker. The computation-only examples provide a lighter path when installing the formal toolchain is unnecessary.

Eight investigations, one interface

The book’s eight opening investigations exercise different failure modes. The same math-engine proof NAME interface is used for all of them.

Investigation Runner name What it lets you inspect
Fermat and Euler fermat A universal claim overturned by exact factorization and formal checks
Cauchy and Abel abel-f1 A checked finite identity and the boundary between finite results and infinite convergence
Haraux and relativity haraux Event definitions, exact rational comparison and verified imported historical evidence
The wrong theorem wrong-theorem A valid kernel result wrongly attached to a different claim by an external gate
The Grasshopper AI proof grasshopper Which declarations depend on sorryAx, using a separately pinned historical audit
Kempe and Heawood kempe Exact graph computation and the dependence on a transcribed historical diagram
Simpson’s paradox simpson Exact rational comparisons before and after aggregation
Gabriel’s horn gabriel A finite-volume integral, an unbounded-area integral and distinct modelling assumptions

The ninth investigation is a separate tutorial for readers who want to extend the laboratory. Its cube/divisibility exercise has a filed pinned run; it is not a ninth historical case in Part I.

Worked examples and notebooks

Every chapter that has a runnable demonstration has a worked example, which opens from the chapter’s Example button, and a Colab notebook with the same program. The Part I examples also show what the laboratory’s recorded run checked.

Part I: the eight investigations

Chapter Worked example Evidence
2 Refute Fermat’s prime formula with one division Fresh kernel check (Lean with Mathlib, and Rocq) plus exact computation (kernel_checked_correspondence_approved)
3 Check the cosine-sum identity behind Abel’s counterexample Fresh kernel check (Lean with Mathlib, one kernel) plus numerical computation (kernel_checked_correspondence_pending)
4 Find where Haraux’s two collision times start Verified historical kernel evidence (imported, not re-run) plus fresh exact computation (historical_verified_correspondence_pending)
5 Catch a correct proof of the wrong theorem Fresh kernel check in core Lean: statement-attachment tests on four cases (kernel_checked_correspondence_pending)
6 Read what the kernel certified about an AI proof Verified historical Lean audit (imported, not re-run), freshly re-read from its kernel logs (historical_verified_correspondence_pending)
7 Break Kempe’s four-colour step on Heawood’s map Exact computation on a transcribed historical graph; no proof kernel (computed_correspondence_pending)
8 See Simpson’s paradox in two published tables, exactly Fresh kernel check (Lean and Rocq) plus exact rational computation (kernel_checked_correspondence_pending)
9 Measure Gabriel’s horn: finite volume, unbounded area Fresh kernel check (Lean with Mathlib, one kernel) plus symbolic and numerical computation (kernel_checked_correspondence_pending)

Part II: the mathematics

Chapter Worked example Evidence
10 Refute a ‘for all’ claim with one exact witness Demonstration program
11 Delete a hypothesis and watch the theorem break Demonstration program
12 Take two limits in both orders and get two answers Demonstration program
13 See where floating point and high precision mislead Demonstration program
14 Walk through the hard case of the five-colour proof Demonstration program
15 Read what a Lean statement actually says Demonstration program
16 Trace what a proof rests on with #print axioms Demonstration program
17 Make two clocks each run slow, without contradiction Demonstration program
18 Check that the interval survives every boost, exactly Demonstration program
19 Settle Gabriel’s paint: one slogan, two kinds of paint Demonstration program

Part III: the laboratory

Chapter Worked example Evidence
20 Pin a claim by hash and watch an approval lapse Demonstration program
21 Run an investigation in miniature, from contract to record Demonstration program
22 See which ‘same statement’ the kernel accepts Demonstration program
23 Break Euler’s factorization on purpose Demonstration program
24 Apply the status rules to seven situations Demonstration program
25 Tamper with a record, then forge one that verifies Demonstration program
26 Audit a Lean file that compiles Demonstration program
27 Put every AI proposal through an exact check Demonstration program
28 Build the ninth investigation: 6 divides n³ − n Demonstration program

Three kinds of evidence

Evidence What happened What it does not establish
kernel_checked A formal checker accepted the specified statements in this execution, subject to the recorded axiom and binding checks That the formal statement automatically captures the intended historical, physical or informal claim
computed An exact computation produced the recorded result A general formal proof, or fidelity of input data transcribed from a source
historical_verified Previously recorded evidence was checked against pinned hashes, with fresh computations where specified That the formal kernel was rerun during this execution

A status may additionally say correspondence_pending or correspondence_approved. Those distinctions concern the relation between formal evidence and the intended claim, not whether a computation happened. Approval is a separate human action; running the software does not create it.

The laboratory’s failure controls are just as important as its positive results. A false volume, a swapped theorem statement or a removed graph boundary should fail for the intended reason. Merely observing a nonzero exit code is insufficient: even a misspelled module can crash and masquerade as a successful negative test.

Open and inspect the notebook

A completed investigation can produce:

  • result.json — machine-readable claim, execution results, evidence identity and status.
  • notebook.md — the narrative report rendered from the result.
  • notebook.ipynb — a notebook representation for exploration and review.
  • SHA256SUMS — file-integrity information for the recorded run.

The recorded evidence can be checked using the runner’s --verify option. For example, for a run stored in out/proof-fermat:

# Run from the repository root with math-engine installed locally.
math-engine proof fermat --verify out/proof-fermat

Verification can detect changed recorded bytes and mismatched evidence identity. It does not, by itself, verify a historical translation, prove that a physical model is appropriate or establish that every mathematical assumption was chosen correctly.

Apply the method to your own mathematics

You do not need to begin with a famous conjecture. Start with a claim small enough to state precisely and challenge.

For example, suppose you believe that a particular divisibility relationship holds for every natural number. Work through the same sequence:

  1. Write the claim with its domain and assumptions. Give the expected result independently of the proof code.
  2. Choose a checking method suited to the claim: Lean or Rocq for a formal proposition, exact computation for finite examples, or both where they make independent contributions.
  3. Construct a failure control by changing one meaningful feature of the claim. Require the failure to occur for the right reason.
  4. Run the investigation in a recorded environment, and inspect the output instead of relying on its headline.
  5. Check correspondence between the intended question and the formalized statement. Record any unresolved interpretation separately from proof execution.
  6. Preserve the evidence so the result can be inspected, challenged and reproduced later.

Part III of the book explains why these boundaries matter. Its tutorial on building a ninth investigation demonstrates the extension path; Part IV documents the registry, commands and file formats. The implementation is in the Math repository.

What the book contributes

The four parts make different contributions to this working environment.

Part Question Contribution to the solution
I — Eight Investigations What goes wrong in real mathematical arguments? Concrete claims, counterexamples, disputed interpretations and executable cases
II — Understanding the Mathematics Why do those results hold or fail? Quantifiers, assumptions, convergence, exact arithmetic, geometry, statistics and relativity
III — The Mathematics Laboratory How can a result be challenged and recorded responsibly? Claim contracts, statement identity, proof auditing, controls, notebooks and AI’s bounded role
IV — Technical Reference How can another reader run and extend it? Docker workflow, runner options, evidence formats, sources, exercises and the tutorial

The book is the explanation; the environment is something the reader can use. Each investigation supplies a reason to question a result and a practical method for checking it.

What exists today

Component Standing
Four-part, 38-chapter book Drafted and assembled in the repository’s BookKit layout; publication is a separate decision
math-env Docker image Pinned local toolchain used for recorded investigations; not a hosted service
math-engine proof Working reader-facing interface for the eight investigations and the tutorial
Lean / Rocq / SymPy / Python Used where the individual investigation requires them; coverage differs by claim
Recorded investigations Run directories with results, notebooks and integrity manifests; fresh and imported evidence remain distinguished
Failure controls Deliberate negative cases with recorded expected outcomes; not a proof of checker soundness
Historical investigation engine Preserved as archive and supplemental validation, not a second reader workflow
General theorem discovery and automatic approval Not provided by this environment

A pinned container reduces variation in execution. It does not guarantee that an informal claim was translated faithfully, that a source figure was transcribed correctly or that independent researchers have reproduced every result. The existing notebooks record those distinctions rather than hiding them.

What the evidence supports

The pinned runs establish that the runner can execute the recorded investigations, distinguish fresh proof checking from computation and historical verification, reject their configured negative controls, and preserve checkable evidence files. The tutorial shows that the same workflow can be applied to a small additional mathematical problem.

They do not establish that every chapter’s historical reading is correct, that all results have received independent human mathematical review, or that the environment can automatically verify arbitrary mathematical prose. In particular, the Haraux interpretation and the fidelity of the transcribed Heawood figure require judgments beyond the runner’s computations.

The solution’s value is not that it removes uncertainty. It makes the source of a result, the kind of check performed and the remaining uncertainty much easier to inspect.

Where to begin

If you want a simple mathematical surprise, begin with Fermat and Euler. Run one claim, read its notebook and see how a single factor changes a universal statement.

If you want to understand how formal checking can be misreported, use The Wrong Theorem and Grasshopper. Compare the statement the kernel checked against the claim someone wanted to establish.

If you want to build rather than only inspect, follow Part III’s ninth-investigation tutorial, then use Part IV as the implementation reference.

Read Adversarial Mathematics: From First Principles · Explore the mathematics laboratory repository

The enduring result of the book is a repeatable habit: state the question, check what was actually proved, challenge the result, and keep the evidence available for the next reader.