Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

sgl_prologue_input

Definition

by Henry Yuen · Jul 27, 2026 · Mathlib 0df444a (Lean v4.33.1)

Definition code
import Definitions.Def_sgl_prologue_inv

/-!
# One input, made ready

Two steps: mark the origin, then make the terminating blank explicit.  Neither
writes anything to the input — the first materialises a blank to its left by
stepping off the origin and back, the second materialises one to its right by
walking to the end and back.  What the round needs from an input tape is only
that both of those cells be named in the representation.

`Tape.ofBits` is the raw form a machine's input arrives in, and it is already a
`cellsTape` with an empty left context, so the two steps compose directly onto
it.
-/

namespace SipserGacsLautemann

variable {tapes : Nat}

/-- The raw input tape, as a `cellsTape`. -/
theorem ofBits_cellsTape (bits : List Bool) :
    Tape.ofBits bits = cellsTape [] (bits.map TapeSymbol.bit) := by
  cases bits with
  | nil => rfl
  | cons b bs => rfl

/-- Input cells are never blank. -/
theorem bitCells_nonblank (bits : List Bool) :
    ∀ c ∈ bits.map TapeSymbol.bit, c ≠ TapeSymbol.blank := by
  intro c hc
  obtain ⟨b, _, rfl⟩ := List.mem_map.mp hc
  simp

/-- Mark the origin, then name the terminating blank. -/
def inputPrep (s w : Fin tapes) :=
  (prepTape s).andThen fun _ => normalizeInput s w

set_option maxHeartbeats 1000000 in
/-- **One input, in the shape a round consumes.** -/
theorem inputPrep_spec (s w : Fin tapes) (hsw : s ≠ w)
    (x : List TapeSymbol) (T : Fin tapes → Tape)
    (hnb : ∀ c ∈ x, c ≠ TapeSymbol.blank)
    (hs : T s = cellsTape [] x) :
    ∃ cost : Nat,
      HaltsExactly (inputPrep s w) ((inputPrep s w).startCfg T) cost true ∧
      (((inputPrep s w).step^[cost]) ((inputPrep s w).startCfg T)).tape =
        Function.update T s
          (cellsTape [TapeSymbol.blank] (x ++ [TapeSymbol.blank])) := by
  classical
  obtain ⟨g1, s1⟩ := prepTape_spec s T x hs
  set T1 := Function.update T s (cellsTape [TapeSymbol.blank] x) with hT1
  have hT1s : T1 s = cellsTape [TapeSymbol.blank] x := by
    rw [hT1, Function.update_self]
  obtain ⟨c2, g2, s2⟩ := normalizeInput_spec s w hsw x T1 hnb hT1s
  have hch := chainStepC g1 s1 g2
  refine ⟨_, hch.1, ?_⟩
  have hfin : ((inputPrep s w).step^[_])
      ((inputPrep s w).startCfg T) = _ := hch.2
  rw [hfin]
  show (((normalizeInput s w).step^[c2])
    ((normalizeInput s w).startCfg T1)).tape = _
  rw [s2, hT1, Function.update_idem]

end SipserGacsLautemann

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