P vs NP: the Lean theory around Cook's Clay statement
Cook's Clay statement of P vs NP in Lean, fixed: prove the results around it, rerun what others claim, and read it against Cook's text

| 1 | # What upstream says |
| 2 | |
| 3 | This project starts from [lean-dojo/LeanMillenniumPrizeProblems](https://github.com/lean-dojo/LeanMillenniumPrizeProblems) at `603053dc267cf3efe422f438eb78098c0ececd6f` (2026-09-10). Its README at that commit follows, unchanged, with its headings moved down two levels; `README.md` and `AGENTS.md` here are this project's. Upstream states all seven Millennium problems; this project holds only its P vs NP files (`upstream.json`), so the paths it names for the other six, `Problems/Registry.lean`, `Tests/AggregateTargets.lean`, `scripts/`, the Clay PDFs and the picture `millennium_problems.png` are not here. |
| 4 | |
| 5 | ## README.md |
| 6 | |
| 7 | ### Millennium Prize Problems in Lean 4 |
| 8 | |
| 9 | This repository contains Lean 4 formulations of the seven Millennium Prize Problems described by |
| 10 | the Clay Mathematics Institute. It focuses on the problem statements and the mathematics needed to |
| 11 | express them, not on claiming solutions. |
| 12 | |
| 13 | <p align="center"> |
| 14 | <img src="millennium_problems.png" alt="The seven Millennium Prize Problems"> |
| 15 | </p> |
| 16 | |
| 17 | #### Getting started |
| 18 | |
| 19 | ```bash |
| 20 | lake exe cache get # Mathlib build cache |
| 21 | lake build # builds the statements (`Problems`) and the checks (`Tests`) |
| 22 | python3 scripts/clay_refs.py verify |
| 23 | ``` |
| 24 | |
| 25 | The second command checks the Lean development. The third verifies the local copies of the official |
| 26 | Clay PDFs. The same three steps run in CI on every push and pull request. |
| 27 | |
| 28 | #### The seven problems |
| 29 | |
| 30 | | Problem | Lean file | Propositions that count as a solution | Status | |
| 31 | |---|---|---|---| |
| 32 | | P versus NP | `Problems/PVersusNP/Millennium.lean` | `Millennium.ClayPVersusNP` (P = NP) or `Millennium.ClayPVersusNP.Formulations.NegativeBranch` (P ≠ NP) | Open | |
| 33 | | Riemann Hypothesis | `Problems/RiemannHypothesis/Millennium.lean` | `Millennium.ClayRiemannHypothesis` | Open | |
| 34 | | Navier–Stokes | `Problems/NavierStokes/Millennium.lean` | any one of `MillenniumNavierStokes.FeffermanA`, `FeffermanB`, `FeffermanC`, `FeffermanD` | Open | |
| 35 | | Birch and Swinnerton-Dyer | `Problems/BirchSwinnertonDyer/Millennium.lean` | `MillenniumBirchSwinnertonDyer.ClayBirchSwinnertonDyer` | Open | |
| 36 | | Poincaré Conjecture | `Problems/Poincare/Millennium.lean` | `MillenniumPoincare.ClayPoincareConjecture` | Solved by Perelman; Lean proof not included | |
| 37 | | Hodge Conjecture | `Problems/Hodge/Millennium.lean` | none | Statement incomplete, not a valid target (see below) | |
| 38 | | Yang–Mills existence and mass gap | `Problems/YangMills/Millennium.lean` | none | Statement incomplete, not a valid target (see below) | |
| 39 | |
| 40 | `Problems/Registry.lean` records the same information as checked Lean metadata, including the |
| 41 | status of each statement. |
| 42 | |
| 43 | #### How to claim a solution |
| 44 | |
| 45 | A solution is a `sorry`-free proof of one of the propositions in the table, using only the |
| 46 | standard axioms (`propext`, `Classical.choice`, `Quot.sound`; check with `#print axioms`). |
| 47 | |
| 48 | - **Riemann, Birch and Swinnerton-Dyer, Poincaré.** Each file ends with a placeholder theorem |
| 49 | `clay_prize_*` whose body is `sorry`. Replace the body. |
| 50 | - **P versus NP and Navier–Stokes.** These problems ask *which* of several alternatives holds, so |
| 51 | the alternatives are exposed as separate propositions and there is no placeholder. There is |
| 52 | deliberately no aggregate declaration either: the disjunction of the alternatives is a classical |
| 53 | tautology, and an inductive type with one constructor per alternative is inhabited by classical |
| 54 | case analysis. Both facts are compiled in `Tests/AggregateTargets.lean`, and the Navier–Stokes |
| 55 | disjunction is proved outright in `Tests/NavierStokes/AggregateIsTrivial.lean` (zero force plus |
| 56 | the scaling symmetry of the equations, no fluid dynamics). |
| 57 | - **Hodge and Yang–Mills.** Not valid targets until the statements are rewritten; see the next |
| 58 | section. |
| 59 | |
| 60 | #### Known incomplete statements |
| 61 | |
| 62 | A review in September 2026 (with an independent contribution by Kevin Buzzard, PR #9) found that |
| 63 | two of the formal statements are interface sketches whose data are not pinned down by the stated |
| 64 | properties. Both files carry a warning at the top, both are marked `statement_incomplete` in the |
| 65 | registry, and their former `sorry` placeholders have been removed. |
| 66 | |
| 67 | - **Hodge.** Every `SmoothProjectiveVariety ℂ` in the repository has no complex points, because |
| 68 | `points` must be in bijection with the plain `Scheme` hom-set `Spec ℂ ⟶ X` and also inject into |
| 69 | a finite projective space, so `ClayHodge` is vacuously true |
| 70 | (`Tests/Hodge/StatementIsVacuous.lean`, contributed by Kevin Buzzard). Independently, the cycle-class map |
| 71 | is free data: setting it to zero preserves every "canonical" anchor, so `ClayHodge` would become |
| 72 | false as soon as the first defect were repaired (`Tests/Hodge/CycleClassUnconstrained.lean`). |
| 73 | A faithful statement needs the analytic topology on `X(ℂ)`, a defined Hodge decomposition and |
| 74 | cycle-class map, and the rational–complex comparison isomorphism, none of which exist in Mathlib. |
| 75 | - **Yang–Mills.** The quantum-field-theory data are not tied to Yang–Mills theory or to |
| 76 | relativity: the gauge field stores connection and curvature independently, the Lie algebra has |
| 77 | no bracket, the Poincaré group is an arbitrary group unrelated to the Hamiltonian, and the |
| 78 | "unbounded" physical Hamiltonian is tied to the spectrum of a bounded operator. The existence |
| 79 | statement can therefore be satisfied by a two-dimensional toy model. (Until September 2026 the |
| 80 | vacuum-uniqueness axiom was also contradictory, which made the theory structure uninhabited; |
| 81 | that slip is fixed.) |
| 82 | |
| 83 | Contributions that replace these sketches with faithful statements are very welcome; they are |
| 84 | substantial projects, not patches. |
| 85 | |
| 86 | #### Formalization scope |
| 87 | |
| 88 | The statements follow the Clay PDFs included in this repository. Some subjects require explicit |
| 89 | interfaces for mathematics that is not yet available directly in Mathlib: |
| 90 | |
| 91 | - Navier–Stokes represents Fefferman's four cases (A)–(D) directly. Fields are smooth on the closed |
| 92 | half-space `ℝ³ × [0,∞)`; the equations and the derivative bounds are imposed on the open |
| 93 | half-space `t > 0`, because the ambient derivative used in the equations is not meaningful on the |
| 94 | boundary. The pressure-periodicity erratum is included. |
| 95 | - P versus NP uses a concrete finite-alphabet Turing-machine model and Cook's verifier definition, |
| 96 | with certificates that are strings over a finite alphabet. |
| 97 | - Birch and Swinnerton-Dyer packages the analytic continuation of the L-series as explicit data; |
| 98 | the target is existential in that data, so a proof must also supply the continuation and a finite |
| 99 | rank. |
| 100 | - Riemann is equivalent to Mathlib's `RiemannHypothesis`; Poincaré is equivalent to the shape of |
| 101 | Mathlib's `proof_wanted` statement. |
| 102 | - Hodge and Yang–Mills are axiomatic sketches, see above. |
| 103 | |
| 104 | The detailed choices and related declarations are listed in `Problems/Registry.lean` and documented |
| 105 | inside the corresponding Lean files. |
| 106 | |
| 107 | #### Tests |
| 108 | |
| 109 | The `Tests` library is built by `lake build` and holds compiled facts about the statements: |
| 110 | sanity checks that must keep holding (equivalences with Mathlib statements, axiom audits, |
| 111 | inhabitation of data types), and regression witnesses that show why certain formulations are not |
| 112 | targets. A regression witness is expected to stop compiling when the statement it exposes is fixed. |
| 113 | |
| 114 | #### Repository layout |
| 115 | |
| 116 | | Path | Contents | |
| 117 | |---|---| |
| 118 | | `Problems/` | The seven statements and their supporting definitions | |
| 119 | | `Problems/Common/` | Definitions shared by several problems | |
| 120 | | `Problems/Registry.lean` | A checked index of the problems, their status, and related declarations | |
| 121 | | `Problems/*/references/clay/` | Local copies of the official Clay PDFs | |
| 122 | | `Tests/` | Compiled sanity checks and regression witnesses | |
| 123 | | `scripts/clay_refs.py` | Downloads or verifies the Clay PDFs | |
| 124 | | `.github/workflows/ci.yml` | Continuous integration: build and PDF verification | |
| 125 | |
| 126 | #### History of statement fixes |
| 127 | |
| 128 | - 2026-04: Navier–Stokes vacuous-domain loophole closed after issue #4. |
| 129 | - 2026-06: Navier–Stokes aggregate disjunction removed after issue #5 (it was reintroduced in |
| 130 | July and removed again in September). |
| 131 | - 2026-09: independent review. Smoothness order fixed to `C^∞` (PR #7); Yang–Mills locality |
| 132 | direction fixed (PR #8); Navier–Stokes equations moved to the open half-space; P versus NP |
| 133 | certificate encoding fixed (every language was in NP); Yang–Mills vacuum-uniqueness axiom fixed; |
| 134 | Birch–Swinnerton-Dyer auxiliary formulations with empty data types removed or weakened; Hodge |
| 135 | and Yang–Mills demoted to `statement_incomplete`; `Tests` library and CI added. |
| 136 | |
| 137 | #### References |
| 138 | |
| 139 | - [Clay Mathematics Institute: Millennium Problems](https://www.claymath.org/millennium-problems/) |
| 140 | - [Lean 4](https://leanprover.github.io/) |
| 141 | - [Mathlib documentation](https://leanprover-community.github.io/mathlib4_docs/) |
| 142 | |
| 143 | #### Contributing |
| 144 | |
| 145 | Contributions that improve the accuracy of the statements, replace temporary mathematical |
| 146 | interfaces with native Mathlib constructions, add tests, or provide formal proofs are welcome. |
| 147 | Statement changes should come with a test in `Tests/` showing that the new statement is not |
| 148 | trivially provable or refutable. |