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

| issue | 45 |
|---|---|
| status | done |
General machine helpers reused by parity
M-2 extracts ten reusable facts into Problems/PVersusNP/ForMathlib/ and
uses every one in the existing Examples/Parity.lean. The two helper modules
import Mathlib only: no Millennium definitions or complexity assumptions.
The parity machine, counted language, input.length + 1 bound and final
evenTrueCount_in_P statement are unchanged. Frozen files, checks, dependencies
and build configuration are unchanged.
Helpers and proposed Mathlib homes
Each declaration is absent at this project's Mathlib pin
fabf563a7c95a166b8d7b6efca11c8b4dc9d911f; the exact source files were read via
GitHub's contents API before implementation. These are proposed destinations,
not a statement of Mathlib acceptance.
| Declaration | Purpose / hypotheses | Proposed Mathlib file |
|---|---|---|
StateTransition.EvalsToInTime.mono |
Preserve a recorded run while weakening m to m', given m ≤ m' |
Mathlib/Computability/StateTransition.lean |
StateTransition.EvalsToInTime.of_step |
A one-step timed run from h : f a = b, including b = none |
Mathlib/Computability/StateTransition.lean |
Turing.initList_l |
Initial label is some tm.main |
Mathlib/Computability/TuringMachine/Computable.lean |
Turing.initList_var |
Initial state is tm.initialState |
Mathlib/Computability/TuringMachine/Computable.lean |
Turing.initList_stk_self |
Input stack contains its supplied list | Mathlib/Computability/TuringMachine/Computable.lean |
Turing.initList_stk_ne |
Stack k is empty when k ≠ tm.k₀ |
Mathlib/Computability/TuringMachine/Computable.lean |
Turing.haltList_l |
Halted label is none |
Mathlib/Computability/TuringMachine/Computable.lean |
Turing.haltList_var |
Halted state resets to tm.initialState |
Mathlib/Computability/TuringMachine/Computable.lean |
Turing.haltList_stk_self |
Output stack contains its supplied list | Mathlib/Computability/TuringMachine/Computable.lean |
Turing.haltList_stk_ne |
Stack k is empty when k ≠ tm.k₁ |
Mathlib/Computability/TuringMachine/Computable.lean |
The timed constructions are defs because EvalsToInTime carries run data in
Type, not a proposition. They are universe-polymorphic and use only the run,
step equation or bound inequality explicitly shown. The projection theorems
apply to any bundled FinTM2, its canonical input/output list and, for the
other-stack lemmas, the stated inequality. No new unproved hypothesis is used.
Parity.run uses of_step and mono; parityDecider uses mono. Its two
configuration bridges use all eight projection lemmas, so clients need not
unfold the dependent conditional stack definitions. The fixed sanity test's
private version is left untouched.
What happened
Claim commit a4070d0 preceded implementation. Lean and Lake are absent locally;
none was installed. The installed Python 3.12 runs the local challenge.
The first build, 1512 at 1af20d4,
compiled both new helper modules but rejected the multiline record syntax at
the parity call sites. Constructor notation fixed that at cad551f, where
1519 found that decide could not
infer an equality decision through the bundled machine's stack type. Explicit
simplification of the concrete stack indices fixed those two call sites.
Both failed attempts remain in branch history.
Verification and reproduction
The source-bearing commit is
8a2d07e8f82b82c737cfbd0ddcf9ad4f0a38e88e.
Challenge 1522 passed on it,
checking 6 Lean files / 2,522 lines. Build 1523
explicitly compiled both ForMathlib modules and the changed Parity module, and
returned ok: lake build passes with no sorry. The parity theorem's printed
axioms remain [propext, Classical.choice, Quot.sound]. See RERUN.md.
On a machine with the pinned Lean and Mathlib, reproduce with
lake build Problems Tests. The local file-only command is:
/Users/wang-thumac/.cache/codex-runtimes/codex-primary-runtime/dependencies/python/bin/python3.12 checks/challenge.py .
A later documentation-only head carries these source-commit verdicts; it does not rerun Lean. No independent rebuild or Mathlib submission is claimed. This is a library refactor and gives no answer to P vs NP.
Next
The project maintainer should review PR #81 and decide whether to merge it for #45. Offer the helpers to Mathlib only after a second nonfixed proof uses them, as the issue requests; this contribution has one client.