A finite stack program writes a canonical binary code from a unary counter
ProvedCookPvsNP.unary_to_encNat_stackbinary-encodingcomplexity-theorystack-program
There are a fixed finite five-stack program and a constant with the following property. For every natural number and every output tail , initialize stack 0 to copies of the symbol , stack 1 to , and the remaining stacks to the empty word. The program halts within
source steps, preserving stack 0, replacing stack 1 by , and leaving the other stacks empty. Here is the published least-significant-bit-first canonical binary encoding with a trailing separator; for it consists only of that separator. The initial source stack is assumed to be a valid unary counter; the statement does not assert termination on arbitrary malformed source stacks.
Preamble
import Definitions.Def_CookPvsNP_StackProgram import Definitions.Def_ProjSchedTW_Complexity_Encoding open CookPvsNP ProjSchedTW.Complexity
Formal statement
namespace CookPvsNP
theorem unary_to_encNat_stack :
∃ (p : StackProg (Fin 5) BSym) (C : ℕ),
∀ (n : ℕ) (tail : List BSym), ∃ steps,
p.Exec
(fun k ↦ if k = 0 then List.replicate n .one else if k = 1 then tail else [])
(fun k ↦ if k = 0 then List.replicate n .one else if k = 1 then encNat n ++ tail else []) steps ∧
steps ≤ C*(n+1)^2 := by
sorry
end CookPvsNPSource
Auxiliary finite-stack implementation for the exact binary tensor encoding in Hillar and Lim, Most Tensor Problems Are NP-Hard, J. ACM 60(6) (2013), arXiv:0911.1393v5, Theorem 1.3 and its proof, pp. 0:20–0:21. This machine-level writer and bound are formalization support, not a theorem explicitly stated in the paper.