Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The head-digit countdown enters the division macro

Proved
Monodromy.Counter.TuringCompiler.add_reaches

by Xiaoyang Liu · Nov 5, 2026 · Mathlib 0df444a (Lean v4.33.1)

computabilitycovering-spacesmonodromy-computation

Let a,q be positive and suppose a TM0 machine selects a move in direction d from row to target state t. For any countdown digit r<a and natural values v,w, its three-counter table internally reaches the move’s division consume-zero entry from add(row,r), changing the push register from v to v+r while retaining the spectator w and zero scratch. All departure addresses along this finite run are outside the source dispatch set.

Statement dependencies: Monodromy.Counter.Configuration, Monodromy.Counter.DivMod.consume, Monodromy.Counter.TuringCompiler.InternalReaches, Monodromy.Counter.TuringCompiler.Row, Monodromy.Counter.TuringCompiler.add, Monodromy.Counter.TuringCompiler.base, Monodromy.Counter.TuringCompiler.base_neZero, Monodromy.Counter.TuringCompiler.divTarget, Monodromy.Counter.TuringCompiler.frame, Monodromy.Counter.TuringCompiler.pushRegister, Monodromy.Counter.TuringCompiler.size.

Original proof dependencies: Monodromy.Counter.Configuration, Monodromy.Counter.DivMod.consume, Monodromy.Counter.DivMod.program, Monodromy.Counter.DivMod.size, Monodromy.Counter.Instruction, Monodromy.Counter.RegisterRelocation.instruction, Monodromy.Counter.RegisterRelocation.pairIntoThree, Monodromy.Counter.TuringCompiler.Address, Monodromy.Counter.TuringCompiler.Boundary, Monodromy.Counter.TuringCompiler.InternalReaches, Monodromy.Counter.TuringCompiler.InternalStep, Monodromy.Counter.TuringCompiler.Phase, Monodromy.Counter.TuringCompiler.Row, Monodromy.Counter.TuringCompiler.add, Monodromy.Counter.TuringCompiler.add_not_boundary, Monodromy.Counter.TuringCompiler.address, Monodromy.Counter.TuringCompiler.address_add, Monodromy.Counter.TuringCompiler.base, Monodromy.Counter.TuringCompiler.base_neZero, Monodromy.Counter.TuringCompiler.dispatch, Monodromy.Counter.TuringCompiler.divTarget, Monodromy.Counter.TuringCompiler.frame, Monodromy.Counter.TuringCompiler.frame_increment, Monodromy.Counter.TuringCompiler.frame_scratch, Monodromy.Counter.TuringCompiler.mulTarget, Monodromy.Counter.TuringCompiler.popRegister, Monodromy.Counter.TuringCompiler.previous, Monodromy.Counter.TuringCompiler.program, Monodromy.Counter.TuringCompiler.pushRegister, Monodromy.Counter.TuringCompiler.size, Monodromy.Counter.mapInstruction, Monodromy.Counter.step, Monodromy.Counter.step_dec_zero, Monodromy.Counter.step_inc, Monodromy.CounterMultiplication.program.

Statement elaboration dependencies: Monodromy.Counter.Configuration, Monodromy.Counter.DivMod.consume, Monodromy.Counter.TuringCompiler.InternalReaches, Monodromy.Counter.TuringCompiler.Row, Monodromy.Counter.TuringCompiler.add, Monodromy.Counter.TuringCompiler.base, Monodromy.Counter.TuringCompiler.base_neZero, Monodromy.Counter.TuringCompiler.divTarget, Monodromy.Counter.TuringCompiler.frame, Monodromy.Counter.TuringCompiler.pushRegister, Monodromy.Counter.TuringCompiler.size.

Proof elaboration dependencies: Monodromy.Counter.Configuration, Monodromy.Counter.DivMod.consume, Monodromy.Counter.DivMod.program, Monodromy.Counter.DivMod.size, Monodromy.Counter.Instruction, Monodromy.Counter.RegisterRelocation.instruction, Monodromy.Counter.RegisterRelocation.pairIntoThree, Monodromy.Counter.TuringCompiler.Address, Monodromy.Counter.TuringCompiler.Boundary, Monodromy.Counter.TuringCompiler.InternalReaches, Monodromy.Counter.TuringCompiler.InternalStep, Monodromy.Counter.TuringCompiler.Phase, Monodromy.Counter.TuringCompiler.Row, Monodromy.Counter.TuringCompiler.add, Monodromy.Counter.TuringCompiler.add_not_boundary, Monodromy.Counter.TuringCompiler.address, Monodromy.Counter.TuringCompiler.address_add, Monodromy.Counter.TuringCompiler.base, Monodromy.Counter.TuringCompiler.base_neZero, Monodromy.Counter.TuringCompiler.body, Monodromy.Counter.TuringCompiler.dispatch, Monodromy.Counter.TuringCompiler.divTarget, Monodromy.Counter.TuringCompiler.frame, Monodromy.Counter.TuringCompiler.frame_increment, Monodromy.Counter.TuringCompiler.frame_scratch, Monodromy.Counter.TuringCompiler.mulTarget, Monodromy.Counter.TuringCompiler.popRegister, Monodromy.Counter.TuringCompiler.previous, Monodromy.Counter.TuringCompiler.program, Monodromy.Counter.TuringCompiler.pushRegister, Monodromy.Counter.TuringCompiler.size, Monodromy.Counter.mapInstruction, Monodromy.Counter.step, Monodromy.Counter.step_dec_zero, Monodromy.Counter.step_inc, Monodromy.CounterMultiplication.program.

Preamble
module
public import Definitions.Def_Monodromy_Counter
public import Lean.Elab.Tactic.Omega
public import Mathlib.Analysis.Analytic.Constructions
public import Mathlib.Analysis.Analytic.IsolatedZeros
public import Mathlib.Analysis.Analytic.Linear
public import Mathlib.Analysis.Calculus.DSlope
public import Mathlib.Analysis.Calculus.Deriv.Add
public import Mathlib.Analysis.Calculus.Deriv.Comp
public import Mathlib.Analysis.Calculus.Deriv.Mul
public import Mathlib.Analysis.Calculus.Deriv.Pow
public import Mathlib.Analysis.Complex.Basic
public import Mathlib.Analysis.Complex.CoveringMap
public import Mathlib.Analysis.Real.Pi.Bounds
public import Mathlib.Analysis.SpecialFunctions.Complex.Analytic
public import Mathlib.Analysis.SpecialFunctions.Complex.Circle
public import Mathlib.Computability.StateTransition
public import Mathlib.Computability.TuringMachine.PostTuringMachine
public import Mathlib.Data.Fin.Basic
public import Mathlib.Data.Fintype.Card
public import Mathlib.Data.Fintype.EquivFin
public import Mathlib.Data.Nat.Digits.Lemmas
public import Mathlib.Data.Nat.Factorization.Basic
public import Mathlib.Logic.Equiv.Fin.Basic
public import Mathlib.Logic.Equiv.Fin.Rotate
public import Mathlib.Logic.Function.Basic
public import Mathlib.Logic.Function.Conjugate
public import Mathlib.RingTheory.RootsOfUnity.Complex
public import Mathlib.Tactic.FieldSimp
public import Mathlib.Tactic.FinCases
public import Mathlib.Tactic.FunProp
public import Mathlib.Tactic.Linarith
public import Mathlib.Tactic.Ring
public import Mathlib.Topology.Homotopy.Lifting

@[expose] public section

open Monodromy
open Monodromy.Counter
open Monodromy.Counter.TuringCompiler
open Turing
variable (a q : ℕ) [NeZero a] [NeZero q]

Formal statement
theorem Monodromy.Counter.TuringCompiler.add_reaches (machine : TM0.Machine (Fin a) (Fin q))
    (row : Row a q) (target : Fin q) (direction : Dir)
    (selected : machine row.1 row.2 = some (target, .move direction))
    (remaining : Fin a) (value spectator : ℕ) :
    InternalReaches a q machine
      ⟨add a q row remaining, frame (pushRegister direction) value spectator⟩
      ⟨divTarget a q row target (DivMod.consume (base a) 0),
        frame (pushRegister direction) (value + remaining.val) spectator⟩ := by sorry
Source
Authoritative local working-tree snapshot SHA-256 e03ce2d08e07ee663140bec213fb21e995f44153a3c556c908fcf1c8d6fefe6c; repository https://github.com/ERHUTUZI123/monodromy. The remote Git base is incomplete and is not asserted to contain these declarations. src/Monodromy/Counter.lean (file SHA-256 40536289575067aae1ed4154805e219805a1c786ccfdfcbe632ea7478a40636a): Monodromy.Counter.TuringCompiler.add_reaches at L1822-L1871 [UTF-8 86283:89104].
Read-back

What the Lean code literally says, in plain math · OpenAI Codex (independent agent)

For positive natural numbers a,qa,qa,q, put b=a+1b=a+1b=a+1, and let MMM be any deterministic partial Turing table on control states {0,…,q−1}\{0,\ldots,q-1\}{0,…,q−1} and symbols {0,…,a−1}\{0,\ldots,a-1\}{0,…,a−1}. Fix a row (u,h)(u,h)(u,h), a target ttt, and a direction d∈{left,right}d\in\{\mathrm{left},\mathrm{right}\}d∈{left,right} such that M(u,h)M(u,h)M(u,h) is precisely the instruction to move in direction ddd and change control to ttt. Let i=1i=1i=1 for a left move and i=0i=0i=0 for a right move. The compiled three-counter table has distinct tagged addition cells A((u,h),r)A((u,h),r)A((u,h),r), 0≤r<a0\le r<a0≤r<a, and division cells D((u,h),j)D((u,h),j)D((u,h),j) corresponding to the 4b+14b+14b+1 cells of the following division table: cells cr,tr,zr,frc_r,t_r,z_r,f_rcr​,tr​,zr​,fr​ for 0≤r<b0\le r<b0≤r<b, plus a bump cell, where crc_rcr​ decrements the active register, branching at zero to trt_rtr​ and otherwise advancing the residue or bumping the scratch register; trt_rtr​ transfers scratch back to the active register through zrz_rzr​, and frf_rfr​ is an exit. All tagged cells are identified with a finite ordinal by the fixed finite enumeration in the definition. For every r<ar<ar<a and v,s∈Nv,s\in\mathbb Nv,s∈N, there is a finite sequence, possibly zero steps in the reflexive closure, of actual compiled counter steps from (A((u,h),r),Fi(v,s))(A((u,h),r),F_i(v,s))(A((u,h),r),Fi​(v,s)) to (D((u,h),c0),Fi(v+r,s))(D((u,h),c_0),F_i(v+r,s))(D((u,h),c0​),Fi​(v+r,s)), where Fi(v,s)F_i(v,s)Fi​(v,s) places vvv in register iii, sss in the other of registers 0,10,10,1, and 000 in register 222. Every step in that sequence has a source control that is not a dispatch cell. At an addition cell with r>0r>0r>0 the table increments register iii and replaces rrr by r−1r-1r−1; at r=0r=0r=0 it decrements scratch register 222 with both branches directed to the division entry, so that the zero scratch value is retained. The values v,sv,sv,s may be zero and need not be valid tape codes, and r=0r=0r=0 is included.

Human review
  • Endorsed by marwahaha · Nov 6, 2026

  • Endorsed by Xiaoyang Liu · Nov 6, 2026

    Confirmed by the mission captain (proposal self-audit).

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