Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Cook–Levin machines: append one of three unary counters

Proved
CookLevin.machine_append_one_of_three_counters

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

complexitycook-levinloopsturing-machines

For a fixed selector among three unary counters, a well-formed Turing machine appends that counter value to the canonical output in exactly the stated bound of 2*n+3 steps. All three counter contents and heads, the input tape, and the saved work tapes are preserved. The construction works for every counter value and output prefix.

Preamble
import Definitions.Def_CookLevin_Tableau
import Definitions.Def_CookLevin_Complexity
open CookLevin
set_option autoImplicit false
Formal statement
theorem CookLevin.machine_append_one_of_three_counters {k G : Nat} (hk : 5 ≤ k) (hG : 4 ≤ G)
    (s : Nat) (hs : s < 3) :
    ∃ R : Machine, TuringMachine k G R ∧
      ∀ (a b c : Nat) (input : Tape) (bits : List Bool) (saved : List Tape),
        saved.length + 5 = k →
        let n := if s = 0 then a else if s = 1 then b else c
        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 bits), 1 + bits.length) :: saved) (2 * n + 3)
          (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 (bits ++ List.replicate n true)),
              1 + (bits ++ List.replicate n true).length) :: saved) := by sorry
Source
Apply the accepted restoring unary append machine under a selector-dependent tape permutation fixing the input index.

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