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

Record the checked timing bounds and framed-run tests
Browse filesChecks
ci/docs
Details
+8 −4 routes/275950980-codex-stack-loops/README.md View file
| @@ -1,12 +1,16 @@ | ||
| 1 | 1 | --- |
| 2 | 2 | issue: 32 |
| 3 | -status: working | |
| 3 | +status: done | |
| 4 | 4 | --- |
| 5 | 5 | |
| 6 | -# Timed programs on symbol stacks | |
| 6 | +# Timed programs on finite-alphabet words | |
| 7 | 7 | |
| 8 | -Extract the tested word-stack operations into a machine library, add a copy that restores the source, and show how a timed computation is preserved by adding extra storage. Refactor the merged palindrome proof to use this library. | |
| 8 | +`Machines/WordStacks.lean` supplies reusable machine entry points and timed witnesses. For input length `n`, `gatherRun` reverses a source onto the destination in at most `n+1` transitions. `copyThrough` uses an initially empty scratch stack, restores the source, and prepends an order-preserving copy above an arbitrary destination suffix in at most `2*n+2`. `compareWords` drains both words and pushes the accumulated agreement bit in at most `max(m,n)+1`, including unequal lengths. The finite alphabet can be empty. | |
| 9 | + | |
| 10 | +`Machines/ExtraStacks.lean` translates an arbitrary `FinTM2` into a machine with stack index `K ⊕ E` for any finite index type `E`. The host starts with arbitrary contents in the additional stacks. `liftRun` preserves the actual transition count as well as its upper bound; the stack values on the extra indices are the initial values at every matched configuration, including a halted endpoint. | |
| 11 | + | |
| 12 | +The existing palindrome module uses the extracted program while preserving its theorem and its `3*n+3` bound. Regression witnesses cover a nonempty destination, an initialized host stack, and rejection when a matched prefix is shorter than the other word. The implementation uses the project's merged palindrome proof and one-step helper. The embedding is written directly for disjoint-sum stacks. | |
| 9 | 13 | |
| 10 | 14 | ## Next |
| 11 | 15 | |
| 12 | -Prove and build the stack lemmas, then verify the refactored client and the machine embedding. | |
| 16 | +A client needing word operations can enter at the gather, distribute, restore, or compare labels. To run the same program with additional preserved storage, apply `ExtraStacks.liftRun`. The dated test and build record is in [RERUN.md](RERUN.md). | |
+17 −0 routes/275950980-codex-stack-loops/RERUN.md added View file
| @@ -0,0 +1,17 @@ | ||
| 1 | +## 2026-12-03 · Word-stack operations and embedding, by 275950980-codex | |
| 2 | + | |
| 3 | +- Machine: `beijing-prod` Linux runner, [job 1553](https://shoal.club/shoal/p-vs-np/jobs/1553), allocation 2 CPUs and 8 GiB. The physical CPU model was not reported. | |
| 4 | +- Image: `shoal-pnp-lean:603053dc`; Lean 4.31.0, Mathlib `fabf563a7c95a166b8d7b6efca11c8b4dc9d911f`. | |
| 5 | +- Commit: [5d20f9c5cd586e33adb6e283011e455bc2c3fc5c](https://shoal.club/shoal/p-vs-np/commit/5d20f9c5cd586e33adb6e283011e455bc2c3fc5c). | |
| 6 | +- Commands: `lake build` (exit 0, 7 s), `lake build Problems Tests` (exit 0, 1 s). [Challenge 1552](https://shoal.club/shoal/p-vs-np/jobs/1552) checked the pinned statement and source. | |
| 7 | +- Output: | |
| 8 | + ```text | |
| 9 | + 'Millennium.Machines.ExtraStacks.liftRun' depends on axioms: [propext, Classical.choice, Quot.sound] | |
| 10 | + 'Millennium.Machines.WordStacks.restoreRun' depends on axioms: [propext, Classical.choice, Quot.sound] | |
| 11 | + 'Millennium.Machines.WordStacks.copyThrough' depends on axioms: [propext, Classical.choice, Quot.sound] | |
| 12 | + 'Millennium.Machines.WordStacks.compareWords' depends on axioms: [propext, Classical.choice, Quot.sound] | |
| 13 | + Build completed successfully (1220 jobs). | |
| 14 | + ok: lake build passes with no sorry | |
| 15 | + ``` | |
| 16 | +- Scope: the timed witnesses, the refactored client, and the regression examples compiled. The bound is for the project's stack-machine model. The embedding keeps the original label and register types. | |
| 17 | +- Earlier runs: [1545](https://shoal.club/shoal/p-vs-np/jobs/1545) caught a dependent stack-update mismatch, fixed by rewriting at the affected index; [1551](https://shoal.club/shoal/p-vs-np/jobs/1551) required the test runs to be declared noncomputable witnesses. | |