Cook–Levin machines: halt position loop
ProvedCookLevin.machine_emit_halt_position_loopcomplexitycook-levinloopsturing-machines
Iterate the exact halt position body across a unary-fuel prefix of positions. Advance the four head/cell counters, preserve the halted-state counter, and restore the position fuel. Give an explicit runtime bound and exact formula prefix.
Preamble
import Definitions.Def_CookLevin_Tableau import Definitions.Def_CookLevin_Complexity open CookLevin set_option autoImplicit false
Formal statement
theorem CookLevin.machine_emit_halt_position_loop {k G : Nat} (hk : 8 ≤ k) (hG : 4 ≤ G)
(symbols : Nat) :
∃ R : Machine, ∃ A B : Nat, TuringMachine k G R ∧
∀ (sh : Shape) (t j n : Nat) (input : Tape) (bits : List Bool)
(fuel : Nat → Symbol) (saved : List Tape),
sh.G = symbols → saved.length + 8 = k →
fuel 0 ≠ oneSymbol →
(∀ i, i < n → fuel (1 + i) = oneSymbol) →
fuel (1 + n) ≠ oneSymbol →
let a := literalN (.Neg (sh.stateVar t sh.Q))
let b := fun p => literalN (.Neg (sh.headVar t j p))
let c := fun p => literalN (.Pos (sh.headVar (t + 1) j p))
let d := fun p => literalN (.Neg (sh.cellVar t j p blankSymbol))
let e := fun p => literalN (.Pos (sh.cellVar (t + 1) j p blankSymbol))
let chunk := (List.range n).flatMap fun p =>
(encodeFormula ([Literal.Neg (sh.stateVar t sh.Q), Literal.Neg (sh.headVar t j p),
Literal.Pos (sh.headVar (t + 1) j p)] :: (List.range sh.G).map fun s =>
[Literal.Neg (sh.stateVar t sh.Q), Literal.Neg (sh.cellVar t j p s),
Literal.Pos (sh.cellVar (t + 1) j p s)])).dropLast
Transforms R
(input ::
(contents (boolsToSymbols (List.replicate (a) true)), 1 + a) ::
(contents (boolsToSymbols (List.replicate (b 0) true)), 1 + b 0) ::
(contents (boolsToSymbols (List.replicate (c 0) true)), 1 + c 0) ::
(contents (boolsToSymbols (List.replicate (d 0) true)), 1 + d 0) ::
(contents (boolsToSymbols (List.replicate (e 0) true)), 1 + e 0) ::
(contents (boolsToSymbols (bits)), 1 + (bits).length) ::
(fuel, 1) ::
saved)
(n * (A * (a + b n + c n + d n + e n) + B + 6) + 4)
(input ::
(contents (boolsToSymbols (List.replicate (a) true)), 1 + a) ::
(contents (boolsToSymbols (List.replicate (b n) true)), 1 + b n) ::
(contents (boolsToSymbols (List.replicate (c n) true)), 1 + c n) ::
(contents (boolsToSymbols (List.replicate (d n) true)), 1 + d n) ::
(contents (boolsToSymbols (List.replicate (e n) true)), 1 + e n) ::
(contents (boolsToSymbols (bits ++ chunk)), 1 + (bits ++ chunk).length) ::
(fuel, 1) ::
saved) := by sorrySource
Compose the five-counter template compiler, fixed counter strides and reusable unary iteration with the actual halt-clause encoding.