Canonical binary block parser: correctness and total linear bound
ProvedCookPvsNP.CanonicalBlockParser.execution_and_boundsbinary-encodingcomplexity-theorystack-program
The canonical binary block parser has two properties.
- For a natural number , a suffix , and an initial status stack , the parser started on consumes exactly the first block, leaves unread, stores the reversed digits of , and pushes two success markers. This takes exactly source-program steps.
- On every input word, including malformed and truncated blocks, the parser halts in at most steps. Both the remaining input and the stored digit stack have length at most .
This bounded parser can be composed with finite-stack implementations of binary reductions. The all-input property here is a termination and size bound; it does not by itself characterize acceptance of every malformed input.
Preamble
import Mathlib import Definitions.Def_CookPvsNP_CanonicalBlockParser
Formal statement
namespace CookPvsNP.CanonicalBlockParser
open CookPvsNP ProjSchedTW.Complexity
theorem execution_and_bounds :
(∀ (n : ℕ) (tail status : List BSym),
parseCanonicalBlockProg.Exec
(store (encNat n ++ tail) [] status)
(store tail (n.bits.map digitSym).reverse (.one :: .one :: status))
(3 * n.bits.length + 7)) ∧
(∀ input status : List BSym, ∃ rest digits outstatus steps,
parseCanonicalBlockProg.Exec (store input [] status) (store rest digits outstatus) steps ∧
steps ≤ 3 * input.length + 7 ∧ digits.length ≤ input.length ∧ rest.length ≤ input.length) := by sorry
end CookPvsNP.CanonicalBlockParserSource
Supporting stack-machine implementation for binary encodings in Agnetis, Mirchandani, Pacciarelli and Pacifici, Scheduling Problems with Two Competing Agents, Operations Research 52(2), 2004, Theorem 9.2, pp. 237–238. Parser behaviour and complexity are auxiliary formalization results, not claims from the paper.