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: give pair map operands explicit concrete types
Browse filesChecks
build Program · lake build, no sorry
Details
challenge Program · statement files and build config
Details
+9 −6 Problems/PVersusNP/Machines/CertificateBound.lean View file
| @@ -420,8 +420,8 @@ private def rejectRun (saved : List (tm.Γ tm.k₀)) : | ||
| 420 | 420 | change TM2.stepAux (guard tm sep reject k (.restore false)) (none, tm.initialState) |
| 421 | 421 | (checkpoint (.restore false) ({} : Work (tm.Γ tm.k₀))).stk = _ |
| 422 | 422 | rw [blank] |
| 423 | - change { l := none, var := (none, tm.initialState), | |
| 424 | - stk := Function.update (Function.update empty (.inr .saved) []) (.inl tm.k₁) [reject] } = _ | |
| 423 | + change TM2.Cfg.mk none (none, tm.initialState) | |
| 424 | + (Function.update (Function.update empty (.inr .saved) []) (.inl tm.k₁) [reject]) = _ | |
| 425 | 425 | rw [clean] |
| 426 | 426 | exact congrArg (fun st => ⟨none, (none, tm.initialState), st⟩) output |
| 427 | 427 | | cons a xs ih => exact beginStep (by certificate_step) ih |
| @@ -471,10 +471,13 @@ def checked {α Γ : Type} [Fintype Γ] {ea : FinEncoding α} | ||
| 471 | 471 | xs ++ sep :: ys := by |
| 472 | 472 | refine (congrArg (List.map h.inputAlphabet.invFun) |
| 473 | 473 | (pair_encoding.encode_eq ea (fin_encoding_string Γ) p)).trans ?_ |
| 474 | - change List.map rawDecode | |
| 475 | - ((ea.encode p.1).map Sum.inl ++ Sum.inr none :: p.2.map (fun b => Sum.inr (some b))) = | |
| 476 | - xs ++ sep :: ys | |
| 477 | - rw [List.map_append, List.map_cons, List.map_map, List.map_map] <;> rfl | |
| 474 | + let left := (ea.encode p.1).map (fun a => (Sum.inl a : ea.Γ ⊕ Option Γ)) | |
| 475 | + let right := p.2.map (fun b => (Sum.inr (some b) : ea.Γ ⊕ Option Γ)) | |
| 476 | + let marker : ea.Γ ⊕ Option Γ := Sum.inr none | |
| 477 | + 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 | |
| 478 | 481 | have noSep : ∀ x ∈ xs, x ≠ sep := by |
| 479 | 482 | intro x hx eq |
| 480 | 483 | obtain ⟨a, _, rfl⟩ := List.mem_map.mp hx |