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: use typed list and halt configuration equalities directly
Browse filesChecks
build Program · lake build, no sorry
Details
challenge Program · statement files and build config
Details
+11 −5 Problems/PVersusNP/Machines/CertificateBound.lean View file
| @@ -414,8 +414,10 @@ private def rejectRun (saved : List (tm.Γ tm.k₀)) : | ||
| 414 | 414 | funext j |
| 415 | 415 | by_cases eq : j = Sum.inl tm.k₁ |
| 416 | 416 | · subst j |
| 417 | - exact (Function.update_self _ _ _).trans (haltList_stk_self _ _).symm | |
| 418 | - · exact (Function.update_of_ne eq _ _).trans (haltList_stk_ne _ _ eq).symm | |
| 417 | + exact (Function.update_self (.inl tm.k₁) [reject] empty).trans | |
| 418 | + (haltList_stk_self (guarded tm sep reject k) [reject]).symm | |
| 419 | + · exact (Function.update_of_ne eq [reject] empty).trans | |
| 420 | + (haltList_stk_ne (guarded tm sep reject k) [reject] eq).symm | |
| 419 | 421 | apply congrArg some |
| 420 | 422 | change TM2.stepAux (guard tm sep reject k (.restore false)) (none, tm.initialState) |
| 421 | 423 | (checkpoint (.restore false) ({} : Work (tm.Γ tm.k₀))).stk = _ |
| @@ -475,9 +477,13 @@ def checked {α Γ : Type} [Fintype Γ] {ea : FinEncoding α} | ||
| 475 | 477 | let right := p.2.map (fun b => (Sum.inr (some b) : ea.Γ ⊕ Option Γ)) |
| 476 | 478 | let marker : ea.Γ ⊕ Option Γ := Sum.inr none |
| 477 | 479 | change List.map rawDecode (List.append left (List.cons marker right)) = xs ++ sep :: ys |
| 478 | - rw [List.map_append, List.map_cons] | |
| 479 | - unfold left right | |
| 480 | - rw [List.map_map, List.map_map] <;> rfl | |
| 480 | + calc | |
| 481 | + _ = List.append (List.map rawDecode left) (List.map rawDecode (marker :: right)) := | |
| 482 | + List.map_append (f := rawDecode) (l₁ := left) (l₂ := marker :: right) | |
| 483 | + _ = xs ++ sep :: ys := | |
| 484 | + congrArg₂ List.append | |
| 485 | + (List.map_map (g := rawDecode) (l := ea.encode p.1)) | |
| 486 | + (congrArg (List.cons (rawDecode marker)) (List.map_map (g := rawDecode) (l := p.2))) | |
| 481 | 487 | have noSep : ∀ x ∈ xs, x ≠ sep := by |
| 482 | 488 | intro x hx eq |
| 483 | 489 | obtain ⟨a, _, rfl⟩ := List.mem_map.mp hx |