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 Problems.PVersusNP.Machines.WordStacks |
| 2 | import Problems.PVersusNP.Machines.ExtraStacks |
| 3 | |
| 4 | /-! Regression checks for copying into a nonempty destination, comparing unequal |
| 5 | words, and keeping an initialized host stack while a subprogram runs. -/ |
| 6 | |
| 7 | namespace Tests.PVersusNP.WordStacks |
| 8 | |
| 9 | noncomputable section |
| 10 | |
| 11 | open Turing StateTransition Millennium.Machines.WordStacks Millennium.Machines.ExtraStacks |
| 12 | |
| 13 | private noncomputable def host := extendMachine (machine Bool) Unit (fun _ => Bool) |
| 14 | private def saved (_ : Unit) : List Bool := [false, true] |
| 15 | |
| 16 | /-- The source is restored and the order of the destination's existing suffix is preserved. -/ |
| 17 | example : EvalsToInTime host.step |
| 18 | (extendCfg (fun _ : Unit => Bool) saved |
| 19 | (atPhase .gather (none, true) [true, false] [] [true] [])) |
| 20 | (some (extendCfg (fun _ : Unit => Bool) saved |
| 21 | (atPhase .compare (none, true) [true, false] [] [true, false, true] []))) 6 := |
| 22 | liftRun (machine Bool) (fun _ : Unit => Bool) saved |
| 23 | (copyThrough [true, false] [true] (none, true) []) |
| 24 | |
| 25 | /-- An extra symbol at the end rejects even when the shorter word matched in full. -/ |
| 26 | example : EvalsToInTime (machine Bool).step |
| 27 | (atPhase .compare (none, true) [true] [] [true, false] []) |
| 28 | (some (cfg none (none, true) ([] : List Bool) [] [] [false])) 3 := by |
| 29 | simpa using compareWords [true] [true, false] (none, true) [] |
| 30 | |
| 31 | end |
| 32 | |
| 33 | end Tests.PVersusNP.WordStacks |