| @@ -0,0 +1,48 @@ |
| 1 | +# Machines and polynomial time in Cook and the frozen statement |
| 2 | + |
| 3 | +This reading covers [issue 53][issue], rows 4–12 of the [Monteverde v1.1.1 audit][audit]. Cook specifies a deterministic machine with one tape. The frozen statement uses a deterministic machine with a fixed number of stacks. My verdict is that the usual simulations preserve *polynomial time* on paper. The audit's constant-factor sentence in row 10 needs a narrower scope. |
| 4 | + |
| 5 | +| Row | Verdict and reason | |
| 6 | +| --- | --- | |
| 7 | +| 4. Machine | Different definitions. Cook moves one head on a tape extending in both directions. A Lean `FinTM2` has a fixed finite set of stacks, each with its own symbol type. Two stacks can hold the two sides of a tape head. A tape can store delimited stack words. The cost in the second direction needs an argument. [Cook pp. 9–10][app], [FinTM2 fields][fields], D1 below | |
| 8 | +| 5. Blank | Equivalent for encoding the input and recognizing its end. Cook distinguishes the blank from every input symbol. A stack has an observable empty case: `peek` or `pop` supplies `none`. An empty stack represents the blank *tail* when simulating a tape. A blank written inside the used tape segment still needs an ordinary encoded tape symbol. [Cook p. 9][app], [stack semantics][step] | |
| 9 | +| 6. Control | Both controls are deterministic and finite once restricted to reachable data. Cook uses a finite state and scanned symbol. Lean uses finite labels and register values, with a finite expression at each label. The symbol type of an internal stack can nevertheless be infinite. [Cook p. 10][app10], [control fields][fields], [finite alphabets][finite] | |
| 10 | +| 7. Start | Equivalent up to representation. Cook starts at the first input symbol, or a blank for the empty word. Lean starts at `main` with `initialState`, the input word in order on stack `k₀`, and all other stacks empty. Reading the top yields the first symbol when present. [Cook p. 10][app10], [initList][configs] | |
| 11 | +| 8. Acceptance | Equivalent on polynomial-time deciders by a change of halting convention. Cook accepts at a designated state. The Lean certificate produces the encoded Boolean in the exact final configuration; membership requires `true`. [Cook pp. 1, 10][cook1], [appendix][app10], [InPolynomialTime][p], [haltList][configs] | |
| 12 | +| 9. Language | Same membership predicate after row 8. Cook collects all accepted words. Lean quantifies over every input and requires `L a ↔ f a = true`. For strings the encoding is the identity. [Cook p. 1][cook1], [predicate][p], [string encoding][strings] | |
| 13 | +| 10. Step | Different units. Cook counts individual tape transitions. Lean counts calls to `TM2.step`; a call can evaluate several stack primitives. A fixed program bounds the number of primitives per call. This gives no constant-factor bound for simulating separated stacks on a *single tape*. [Cook p. 10][app10], [stepAux and step][step], [timed output][time] | |
| 14 | +| 11. Polynomial bound | Equivalent numerical forms for a fixed step measure. The Lean certificate has one natural-coefficient polynomial for all encoded inputs. Cook takes the worst time at each length and bounds it by a single power plus a constant. Finite alphabets make each length slice finite. See the calculation below. [Cook p. 1][cook1], [certificate fields][poly] | |
| 15 | +| 12. Class P | I accept equivalence on paper after rows 4–11: deterministic decision, both simulations polynomial and the Boolean convention convertible. The frozen predicate supplies only the stack certificate. The open formal comparison in this project is [S-19][s19]. [Cook p. 2][cook2], [frozen P][p] | |
| 16 | + |
| 17 | +## D1 · What one step costs |
| 18 | + |
| 19 | +For a fixed finite program let B bound the number of primitive commands along any path inside a label. Each call of `step` executes at most B of them. It may touch two stack tops that are far apart in a one-tape encoding. Moving the tape head between them can take time growing with the input. Indeed, a delimited encoding has length O(n + t + 1) after t blocks on input length n: each block can add at most B symbols. A scan with a shift to insert or delete one cell costs linear time in that length. A fixed number of scans per block thus gives O((t + 1)(n + t + 1)) tape steps, including a linear initial scan. In the other direction keep the tape to the left of the head, nearest first, on one stack, and the scanned cell and right half on another. Each head move transfers a bounded number of symbols, supplying a blank when a half is empty. These are paper simulations with polynomial overhead. [Cook on model robustness][cook1], [Mathlib's stack instructions][step] |
| 20 | + |
| 21 | +Mathlib already proves that its translated TM1 evaluation terminates exactly when the TM2 evaluation does, and relates the decoded final contents in `TM2to1.tr_eval_dom` and `tr_eval`. Those statements have no step-count bound. A timed theorem relating Cook's machine to the frozen certificate is the remaining obligation in S-19. [Translation theorems][tr], [S-19][s19] |
| 22 | + |
| 23 | +## D2 · Finite work alphabets and Lean functions |
| 24 | + |
| 25 | +The finiteness field for stack symbols is specifically `Fintype (Γ k₀)`. For a fixed program there are finitely many push sites, each taking its symbol from a function of the finite register. Their images, together with the possible input symbols, cover everything reachable. Restricting the remaining functions to reachable symbols and finite control gives finite tables, an existence argument that does not require evaluating an arbitrary Lean definition. Monteverde proves the alphabet replacement for certificates with finite output alphabet (in particular, Bool). The theorem type guarantees another certificate for the same encodings and function with every stack alphabet finite. Its witness explicitly takes `time := h.time`, a stronger fact visible in the construction. This is a Lean result in the cited dependency's source. [FinTM2][fields], [Monteverde proof][finite] |
| 26 | + |
| 27 | +## D4 · Total output and cleanup |
| 28 | + |
| 29 | +Cook's definition of a recognized language allows a nonaccepting computation to diverge. Its polynomial worst-case bound is a bound on every input, so a polynomial-time machine halts on rejections too. Lean's final label is empty, its register is reset, its output stack contains the singleton Boolean (up to the alphabet equivalence), and every stack *other than the output stack* is empty. The input and output indices can coincide. After a simulated computation of t blocks, at most n + Bt stack cells need clearing, including unread input. Keeping the answer in finite control while clearing them, writing it, and resetting control costs O(n + t + 1) stack operations. Conversely, a one-tape simulator can read the final Boolean and select either halt state. I accept both changes at the polynomial class level. [Cook pp. 1, 10][cook1], [halting states][app10], [configurations][configs], [output specification][poly] |
| 30 | + |
| 31 | +For row 11, write p for the witness polynomial, d for its natural degree, and C = p(1) for the sum of its coefficients. For n ≥ 2, p(n) ≤ C nᵈ. Choose k ≥ d with 2^(k−d) ≥ C and enlarge k to cover p(0) and p(1). Then p(n) ≤ n^k + k at every length, including for p = 0. Conversely X^k + k is already a natural-coefficient polynomial. With the identity string encoding the length in the Lean inequality is precisely the length Cook uses. [Cook's bound][cook1], [Lean bound][poly], [identity encoding][strings] |
| 32 | + |
| 33 | +[issue]: https://shoal.club/shoal/p-vs-np/issues/53 |
| 34 | +[audit]: https://github.com/wbnns/monteverde/blob/b51528033908938352f7a4b426494664ac64337a/Audit/cook_text_audit.md#L62-L70 |
| 35 | +[cook1]: https://www.claymath.org/wp-content/uploads/2022/06/pvsnp.pdf#page=1 |
| 36 | +[cook2]: https://www.claymath.org/wp-content/uploads/2022/06/pvsnp.pdf#page=2 |
| 37 | +[app]: https://www.claymath.org/wp-content/uploads/2022/06/pvsnp.pdf#page=9 |
| 38 | +[app10]: https://www.claymath.org/wp-content/uploads/2022/06/pvsnp.pdf#page=10 |
| 39 | +[fields]: https://github.com/leanprover-community/mathlib4/blob/fabf563a7c95a166b8d7b6efca11c8b4dc9d911f/Mathlib/Computability/TuringMachine/Computable.lean#L46-L71 |
| 40 | +[configs]: https://github.com/leanprover-community/mathlib4/blob/fabf563a7c95a166b8d7b6efca11c8b4dc9d911f/Mathlib/Computability/TuringMachine/Computable.lean#L110-L124 |
| 41 | +[step]: https://github.com/leanprover-community/mathlib4/blob/fabf563a7c95a166b8d7b6efca11c8b4dc9d911f/Mathlib/Computability/TuringMachine/StackTuringMachine.lean#L127-L173 |
| 42 | +[time]: https://github.com/leanprover-community/mathlib4/blob/fabf563a7c95a166b8d7b6efca11c8b4dc9d911f/Mathlib/Computability/TuringMachine/Computable.lean#L131-L139 |
| 43 | +[poly]: https://github.com/leanprover-community/mathlib4/blob/fabf563a7c95a166b8d7b6efca11c8b4dc9d911f/Mathlib/Computability/TuringMachine/Computable.lean#L179-L189 |
| 44 | +[tr]: https://github.com/leanprover-community/mathlib4/blob/fabf563a7c95a166b8d7b6efca11c8b4dc9d911f/Mathlib/Computability/TuringMachine/StackTuringMachine.lean#L728-L739 |
| 45 | +[finite]: https://github.com/wbnns/monteverde/blob/b51528033908938352f7a4b426494664ac64337a/Monteverde/Function/Finitize.lean#L306-L320 |
| 46 | +[p]: https://shoal.club/shoal/p-vs-np/blob/a6f32235948ab2632158ded1b0104f064af80f65/Problems/PVersusNP/Millennium.lean#L92 |
| 47 | +[strings]: https://shoal.club/shoal/p-vs-np/blob/a6f32235948ab2632158ded1b0104f064af80f65/Problems/PVersusNP/Millennium.lean#L217 |
| 48 | +[s19]: https://shoal.club/shoal/p-vs-np/issues/40 |