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

Check the frame, existing destination contents and unequal-length rejection
Browse filesChecks
build Program · lake build, no sorry
Details
challenge Program · statement files and build config
Details
+4 −0 Problems/PVersusNP/Machines/WordStacks.lean View file
| @@ -267,6 +267,10 @@ theorem halt_eq (out : List Bool) : | ||
| 267 | 267 | funext k |
| 268 | 268 | cases k <;> rfl |
| 269 | 269 | |
| 270 | +#print axioms restoreRun | |
| 271 | +#print axioms copyThrough | |
| 272 | +#print axioms compareWords | |
| 273 | + | |
| 270 | 274 | end |
| 271 | 275 | |
| 272 | 276 | end Millennium.Machines.WordStacks |
+29 −0 Tests/PVersusNP/WordStacks.lean added View file
| @@ -0,0 +1,29 @@ | ||
| 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 | +open Turing StateTransition Millennium.Machines.WordStacks Millennium.Machines.ExtraStacks | |
| 10 | + | |
| 11 | +private noncomputable def host := extendMachine (machine Bool) Unit (fun _ => Bool) | |
| 12 | +private def saved (_ : Unit) : List Bool := [false, true] | |
| 13 | + | |
| 14 | +/-- The source is restored and the order of the destination's existing suffix is preserved. -/ | |
| 15 | +example : EvalsToInTime host.step | |
| 16 | + (extendCfg (fun _ : Unit => Bool) saved | |
| 17 | + (atPhase .gather (none, true) [true, false] [] [true] [])) | |
| 18 | + (some (extendCfg (fun _ : Unit => Bool) saved | |
| 19 | + (atPhase .compare (none, true) [true, false] [] [true, false, true] []))) 6 := | |
| 20 | + liftRun (machine Bool) (fun _ : Unit => Bool) saved | |
| 21 | + (copyThrough [true, false] [true] (none, true) []) | |
| 22 | + | |
| 23 | +/-- An extra symbol at the end rejects even when the shorter word matched in full. -/ | |
| 24 | +example : EvalsToInTime (machine Bool).step | |
| 25 | + (atPhase .compare (none, true) [true] [] [true, false] []) | |
| 26 | + (some (cfg none (none, true) ([] : List Bool) [] [] [false])) 3 := by | |
| 27 | + simpa using compareWords [true] [true, false] (none, true) [] | |
| 28 | + | |
| 29 | +end Tests.PVersusNP.WordStacks | |