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

| 1 | import Mathlib.Computability.TuringMachine.Computable |
| 2 | |
| 3 | /-! |
| 4 | # Stack configuration API for bundled machines |
| 5 | |
| 6 | The initial and halted configurations select exactly one designated stack. |
| 7 | These lemmas expose their label, state and stacks without requiring a client |
| 8 | to unfold their dependent conditional definitions. They use only Mathlib's |
| 9 | machine model; their proposed upstream home is |
| 10 | `Mathlib/Computability/TuringMachine/Computable.lean`. |
| 11 | -/ |
| 12 | |
| 13 | namespace Turing |
| 14 | |
| 15 | /-- The initial configuration starts at the machine's main label. -/ |
| 16 | @[simp] theorem initList_l (tm : FinTM2) (s : List (tm.Γ tm.k₀)) : |
| 17 | (initList tm s).l = some tm.main := rfl |
| 18 | |
| 19 | /-- The initial configuration uses the machine's initial state. -/ |
| 20 | @[simp] theorem initList_var (tm : FinTM2) (s : List (tm.Γ tm.k₀)) : |
| 21 | (initList tm s).var = tm.initialState := rfl |
| 22 | |
| 23 | /-- The input stack of the initial configuration contains the input list. -/ |
| 24 | @[simp] theorem initList_stk_self (tm : FinTM2) (s : List (tm.Γ tm.k₀)) : |
| 25 | (initList tm s).stk tm.k₀ = s := by |
| 26 | simp [initList] |
| 27 | |
| 28 | /-- Every stack other than the input stack is initially empty. -/ |
| 29 | @[simp] theorem initList_stk_ne (tm : FinTM2) (s : List (tm.Γ tm.k₀)) |
| 30 | {k : tm.K} (h : k ≠ tm.k₀) : (initList tm s).stk k = [] := by |
| 31 | simp [initList, h] |
| 32 | |
| 33 | /-- The halted configuration has no current label. -/ |
| 34 | @[simp] theorem haltList_l (tm : FinTM2) (s : List (tm.Γ tm.k₁)) : |
| 35 | (haltList tm s).l = none := rfl |
| 36 | |
| 37 | /-- The halted configuration resets to the machine's initial state. -/ |
| 38 | @[simp] theorem haltList_var (tm : FinTM2) (s : List (tm.Γ tm.k₁)) : |
| 39 | (haltList tm s).var = tm.initialState := rfl |
| 40 | |
| 41 | /-- The output stack of the halted configuration contains the output list. -/ |
| 42 | @[simp] theorem haltList_stk_self (tm : FinTM2) (s : List (tm.Γ tm.k₁)) : |
| 43 | (haltList tm s).stk tm.k₁ = s := by |
| 44 | simp [haltList] |
| 45 | |
| 46 | /-- Every stack other than the output stack is empty in the halted configuration. -/ |
| 47 | @[simp] theorem haltList_stk_ne (tm : FinTM2) (s : List (tm.Γ tm.k₁)) |
| 48 | {k : tm.K} (h : k ≠ tm.k₁) : (haltList tm s).stk k = [] := by |
| 49 | simp [haltList, h] |
| 50 | |
| 51 | end Turing |