Cook–Levin machines: five counter template
ProvedCookLevin.machine_emit_five_counter_templatecomplexitycook-levinloopsturing-machines
Compile any fixed clause template with literal values given by offsets from five runtime unary counters. Preserve all five counters and work tapes; append the encoded clauses without the final formula terminator in time affine in the counter sum.
Preamble
import Definitions.Def_CookLevin_Tableau import Definitions.Def_CookLevin_Complexity open CookLevin set_option autoImplicit false
Formal statement
theorem CookLevin.machine_emit_five_counter_template {k G : Nat} (hk : 7 ≤ k) (hG : 4 ≤ G)
(φ : List (List (Fin 5 × Nat))) :
∃ R : Machine, ∃ A B : Nat, TuringMachine k G R ∧
∀ (a b c d e : Nat) (input : Tape) (bits : List Bool) (saved : List Tape),
saved.length + 7 = k →
let chunk := φ.flatMap fun ns => true :: encodeListNat
(ns.map fun x => (if x.1.val = 0 then a else if x.1.val = 1 then b else if x.1.val = 2 then c else if x.1.val = 3 then d else e) + x.2)
Transforms R
(input :: (contents (boolsToSymbols (List.replicate a true)), 1 + a) ::
(contents (boolsToSymbols (List.replicate b true)), 1 + b) ::
(contents (boolsToSymbols (List.replicate c true)), 1 + c) ::
(contents (boolsToSymbols (List.replicate d true)), 1 + d) ::
(contents (boolsToSymbols (List.replicate e true)), 1 + e) ::
(contents (boolsToSymbols bits), 1 + bits.length) :: saved) (A * (a + b + c + d + e) + B)
(input :: (contents (boolsToSymbols (List.replicate a true)), 1 + a) ::
(contents (boolsToSymbols (List.replicate b true)), 1 + b) ::
(contents (boolsToSymbols (List.replicate c true)), 1 + c) ::
(contents (boolsToSymbols (List.replicate d true)), 1 + d) ::
(contents (boolsToSymbols (List.replicate e true)), 1 + e) ::
(contents (boolsToSymbols (bits ++ chunk)), 1 + (bits ++ chunk).length) :: saved) := by sorrySource
Compose the three-counter template compiler, fixed counter strides and reusable unary iteration with the actual inertia-clause encoding.