Cook–Levin machines: transition tape block with aligned counters
ProvedCookLevin.machine_emit_transition_tape_blockcomplexitycook-levinloopsturing-machines
Emit the exact guarded head and write clauses at all positions on one logical tape, then align the current-head, next-head and next-cell counters at position zero of the next tape. Forward increments handle all three movement directions. The width fuel is restored and the runtime has an explicit polynomial-in-counter bound.
Preamble
import Definitions.Def_CookLevin_Reduction import Definitions.Def_CookLevin_Complexity open CookLevin set_option autoImplicit false
Formal statement
theorem CookLevin.machine_emit_transition_tape_block {k G : Nat} (hk : 8 ≤ k) (hG : 4 ≤ G)
(tapes symbols q : Nat) (rs : List Symbol) (action : Action) :
∃ R : Machine, ∃ A B : Nat, TuringMachine k G R ∧
∀ (sh : Shape) (t j : Nat) (input : Tape) (bits : List Bool)
(fuel : Nat → Symbol) (saved : List Tape),
sh.k = tapes → sh.G = symbols → saved.length + 8 = k →
fuel 0 ≠ oneSymbol →
(∀ i, i < sh.T → fuel (1 + i) = oneSymbol) →
fuel (1 + sh.T) ≠ oneSymbol →
let a := literalN (.Neg (sh.stateVar t 0))
let b := literalN (.Neg (sh.readVar t 0 0))
let c := fun j => literalN (.Neg (sh.headVar t j 0))
let d := fun j => literalN (.Pos (sh.headVar (t + 1) j 0))
let e := fun j => literalN (.Pos (sh.cellVar (t + 1) j 0 blankSymbol))
let chunk := (List.range (sh.T + 1)).flatMap fun p =>
(encodeFormula
[guardClause sh t q rs ++ [Literal.Neg (sh.headVar t j p),
Literal.Pos (sh.headVar (t + 1) j (movePos action.2 p))],
guardClause sh t q rs ++ [Literal.Neg (sh.headVar t j p),
Literal.Pos (sh.cellVar (t + 1) j p action.1)]]).dropLast
Transforms R
(input ::
(contents (boolsToSymbols (List.replicate a true)), 1 + a) ::
(contents (boolsToSymbols (List.replicate b true)), 1 + b) ::
(contents (boolsToSymbols (List.replicate (c j) true)), 1 + c j) ::
(contents (boolsToSymbols (List.replicate (d j) true)), 1 + d j) ::
(contents (boolsToSymbols (List.replicate (e j) true)), 1 + e j) ::
(contents (boolsToSymbols bits), 1 + bits.length) :: (fuel, 1) :: saved)
((sh.T + 1) * (A * (a + b + c (j + 1) + d (j + 1) + e (j + 1)) + B) + 4)
(input ::
(contents (boolsToSymbols (List.replicate a true)), 1 + a) ::
(contents (boolsToSymbols (List.replicate b true)), 1 + b) ::
(contents (boolsToSymbols (List.replicate (c (j + 1)) true)), 1 + c (j + 1)) ::
(contents (boolsToSymbols (List.replicate (d (j + 1)) true)), 1 + d (j + 1)) ::
(contents (boolsToSymbols (List.replicate (e (j + 1)) true)), 1 + e (j + 1)) ::
(contents (boolsToSymbols (bits ++ chunk)), 1 + (bits ++ chunk).length) :: (fuel, 1) :: saved) := by sorrySource
Input-dependent initialization for the Cook–Levin reduction.