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

Carry the original finite structures and rewrite only the changed stack
Browse filesChecks
build Program · lake build, no sorry
Details
challenge Program · statement files and build config
Details
+12 −2 Problems/PVersusNP/Machines/ExtraStacks.lean View file
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | import Mathlib.Computability.TuringMachine.Computable |
| 2 | +import Mathlib.Data.Fintype.Sum | |
| 2 | 3 | |
| 3 | 4 | /-! |
| 4 | 5 | # Adding untouched stacks to a finite stack machine |
| @@ -58,11 +59,17 @@ private theorem block_correct (q : TM2.Stmt Γ Λ σ) (v : σ) (st : ∀ k, List | ||
| 58 | 59 | extendCfg extra saved (TM2.stepAux q v st) := by |
| 59 | 60 | induction q generalizing v st with |
| 60 | 61 | | push k f q ih => |
| 61 | - simpa only [translate, TM2.stepAux, joined_update, joined] using ih v (Function.update st k (f v :: st k)) | |
| 62 | + change TM2.stepAux (translate extra q) v | |
| 63 | + (Function.update (joined extra st saved) (.inl k) (f v :: st k)) = _ | |
| 64 | + rw [joined_update] | |
| 65 | + exact ih v (Function.update st k (f v :: st k)) | |
| 62 | 66 | | peek k f q ih => |
| 63 | 67 | exact ih (f v (st k).head?) st |
| 64 | 68 | | pop k f q ih => |
| 65 | - simpa only [translate, TM2.stepAux, joined_update, joined] using ih (f v (st k).head?) (Function.update st k (st k).tail) | |
| 69 | + change TM2.stepAux (translate extra q) (f v (st k).head?) | |
| 70 | + (Function.update (joined extra st saved) (.inl k) (st k).tail) = _ | |
| 71 | + rw [joined_update] | |
| 72 | + exact ih (f v (st k).head?) (Function.update st k (st k).tail) | |
| 66 | 73 | | load f q ih => exact ih (f v) st |
| 67 | 74 | | branch f q r ih ir => |
| 68 | 75 | cases hf : f v <;> simp only [translate, TM2.stepAux, hf, cond_false, cond_true, ih, ir] |
| @@ -83,12 +90,15 @@ private theorem step_correct (prog : Λ → TM2.Stmt Γ Λ σ) (saved : ∀ e, L | ||
| 83 | 90 | def extendMachine (tm : FinTM2) (E : Type) [DecidableEq E] [Fintype E] |
| 84 | 91 | (extra : E → Type) : FinTM2 where |
| 85 | 92 | K := tm.K ⊕ E |
| 93 | + kFin := by letI := tm.kFin; infer_instance | |
| 86 | 94 | k₀ := .inl tm.k₀ |
| 87 | 95 | k₁ := .inl tm.k₁ |
| 88 | 96 | Γ := ExtendedAlphabet tm.Γ extra |
| 89 | 97 | Λ := tm.Λ |
| 98 | + ΛFin := tm.ΛFin | |
| 90 | 99 | main := tm.main |
| 91 | 100 | σ := tm.σ |
| 101 | + σFin := tm.σFin | |
| 92 | 102 | initialState := tm.initialState |
| 93 | 103 | Γk₀Fin := tm.Γk₀Fin |
| 94 | 104 | m l := translate extra (tm.m l) |