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

fix: annotate the halted configuration label and phase types
Browse filesChecks
build Program · lake build, no sorry
Details
challenge Program · statement files and build config
Details
ci/docs
Details
+5 −5 Problems/PVersusNP/Machines/CertificateBound.lean View file
| @@ -402,7 +402,7 @@ private def rejectRun (saved : List (tm.Γ tm.k₀)) : | ||
| 402 | 402 | | nil => |
| 403 | 403 | apply oneStep |
| 404 | 404 | let empty (j : tm.K ⊕ Aux) : List (Alphabet tm j) := [] |
| 405 | - have blank : (checkpoint (.restore false : Phase k) ({} : Work (tm.Γ tm.k₀))).stk = empty := by | |
| 405 | + have blank : (checkpoint (tm := tm) (.restore false : Phase k) ({} : Work (tm.Γ tm.k₀))).stk = empty := by | |
| 406 | 406 | funext j |
| 407 | 407 | cases j with |
| 408 | 408 | | inl j => exact initEmpty tm j |
| @@ -420,12 +420,12 @@ private def rejectRun (saved : List (tm.Γ tm.k₀)) : | ||
| 420 | 420 | (haltList_stk_ne (guarded tm sep reject k) [reject] eq).symm |
| 421 | 421 | apply congrArg some |
| 422 | 422 | change TM2.stepAux (guard tm sep reject k (.restore false)) (none, tm.initialState) |
| 423 | - (checkpoint (.restore false) ({} : Work (tm.Γ tm.k₀))).stk = _ | |
| 423 | + (checkpoint (tm := tm) (.restore false : Phase k) ({} : Work (tm.Γ tm.k₀))).stk = _ | |
| 424 | 424 | rw [blank] |
| 425 | - change TM2.Cfg.mk none (none, tm.initialState) | |
| 425 | + change TM2.Cfg.mk (Λ := Phase k ⊕ tm.Λ) none (none, tm.initialState) | |
| 426 | 426 | (Function.update (Function.update empty (.inr .saved) []) (.inl tm.k₁) [reject]) = _ |
| 427 | 427 | rw [clean] |
| 428 | - exact congrArg (fun st => ⟨none, (none, tm.initialState), st⟩) output | |
| 428 | + exact congrArg (TM2.Cfg.mk none (none, tm.initialState)) output | |
| 429 | 429 | | cons a xs ih => exact beginStep (by certificate_step) ih |
| 430 | 430 | |
| 431 | 431 | private theorem initial (inp : List (tm.Γ tm.k₀)) : |
| @@ -509,7 +509,7 @@ def checked {α Γ : Type} [Fintype Γ] {ea : FinEncoding α} | ||
| 509 | 509 | (EvalsTo.trans _ _ _ _ cleared compared)) |
| 510 | 510 | have lengths : (m ≤ cap) ↔ |
| 511 | 511 | p.2.length ≤ (ea.encode p.1).length ^ k := by |
| 512 | - simp only [m, cap, n, xs, ys, Nat.zero_add, Nat.one_mul, List.length_map] <;> rfl | |
| 512 | + simp only [m, cap, n, xs, ys, Nat.zero_add, Nat.one_mul, List.length_map] | |
| 513 | 513 | have started := (congrArg (initList (guarded h.tm sep reject k)) inputEq).trans |
| 514 | 514 | (initial (sep := sep) (reject := reject) (k := k) (xs ++ sep :: ys)) |
| 515 | 515 | let finish (b : Bool) : (guarded h.tm sep reject k).Cfg := |