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 | import Mathlib.Computability.StateTransition |
| 2 | |
| 3 | /-! |
| 4 | # General timed state-transition helpers |
| 5 | |
| 6 | These definitions mention only Mathlib's state-transition model, with no machine |
| 7 | or complexity-class assumptions. Their proposed upstream home is |
| 8 | `Mathlib/Computability/StateTransition.lean`, beside `EvalsToInTime.refl` and |
| 9 | `EvalsToInTime.trans`. |
| 10 | |
| 11 | `EvalsToInTime` stores a run and its step count as data, so the constructors below |
| 12 | are definitions rather than propositions. |
| 13 | -/ |
| 14 | |
| 15 | universe u |
| 16 | |
| 17 | namespace StateTransition |
| 18 | |
| 19 | /-- A computation within `m` steps is also a computation within any larger bound. |
| 20 | This preserves both the recorded run and its exact step count. -/ |
| 21 | def EvalsToInTime.mono {σ : Type u} {f : σ → Option σ} {a : σ} {b : Option σ} |
| 22 | {m m' : ℕ} (h : EvalsToInTime f a b m) (hm : m ≤ m') : |
| 23 | EvalsToInTime f a b m' := |
| 24 | ⟨h.toEvalsTo, le_trans h.steps_le_m hm⟩ |
| 25 | |
| 26 | /-- A single transition, including a transition to `none`, gives a one-step run. |
| 27 | The resulting witness records exactly one step. -/ |
| 28 | def EvalsToInTime.of_step {σ : Type u} {f : σ → Option σ} {a : σ} {b : Option σ} |
| 29 | (h : f a = b) : EvalsToInTime f a b 1 := |
| 30 | { steps := 1 |
| 31 | evals_in_steps := by simpa [flip, Option.bind] using h |
| 32 | steps_le_m := le_rfl } |
| 33 | |
| 34 | end StateTransition |