Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Cook–Levin machines: reusable link position loop

Proved
CookLevin.machine_emit_link_position_loop

by Robertboy18 · Sep 22, 2026 · Mathlib 0df444a (Lean v4.33.1)

complexitycook-levinloopsturing-machines

Emit actual head-cell-read link clauses for n positions at one time and logical tape. The head and cell counters advance to position n; read counter and saved tapes are unchanged. Unary position fuel is restored to head one for reuse. Runtime n*(A*(a n+b n+c)+B+6)+4. Explicit fuel marker and terminator assumptions; zero symbols and zero length allowed.

Preamble
import Definitions.Def_CookLevin_Tableau
import Definitions.Def_CookLevin_Complexity
open CookLevin
set_option autoImplicit false
Formal statement
theorem CookLevin.machine_emit_link_position_loop {k G : Nat} (hk : 6 ≤ 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 + 6 = k →
        fuel 0 ≠ oneSymbol →
        (∀ i, i < n → fuel (1 + i) = oneSymbol) →
        fuel (1 + n) ≠ oneSymbol →
        let a := fun p => literalN (.Neg (sh.headVar t j p))
        let b := fun p => literalN (.Neg (sh.cellVar t j p blankSymbol))
        let c := literalN (.Pos (sh.readVar t j blankSymbol))
        let chunk := (List.range n).flatMap fun p =>
          (encodeFormula ((List.range sh.G).map fun s =>
      [Literal.Neg (sh.headVar t j p), Literal.Neg (sh.cellVar t j p s),
       Literal.Pos (sh.readVar t j s)])).dropLast
        Transforms R
          (input :: (contents (boolsToSymbols (List.replicate (a 0) true)), 1 + a 0) ::
            (contents (boolsToSymbols (List.replicate (b 0) true)), 1 + b 0) ::
            (contents (boolsToSymbols (List.replicate c true)), 1 + c) ::
            (contents (boolsToSymbols bits), 1 + bits.length) :: (fuel, 1) :: saved)
          (n * (A * (a n + b n + c) + B + 6) + 4)
          (input :: (contents (boolsToSymbols (List.replicate (a n) true)), 1 + a n) ::
            (contents (boolsToSymbols (List.replicate (b n) true)), 1 + b n) ::
            (contents (boolsToSymbols (List.replicate c true)), 1 + c) ::
            (contents (boolsToSymbols (bits ++ chunk)), 1 + (bits ++ chunk).length) ::
            (fuel, 1) :: saved) := by sorry
Source
Compose accepted literal emission, fixed counter increments, and reusable unary iteration with an exact output-prefix invariant.

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me