Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Every recording step preserves its natural-domain invariant

Proved
Monodromy.Counter.Reversible.Recording.valid_step

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

computabilitycovering-spacesmonodromy-computation

For arbitrary natural n,m and source n-counter program P, every successful step of its reversible recording table from a Valid state reaches another Valid state. Valid requires nonnegative original registers and the history/workspace radix conditions at copied ports; at decrement middle ports it requires nonnegative history, zero workspace and positivity of the register awaiting decrement.

Statement dependencies: Monodromy.Counter.Program, Monodromy.Counter.Reversible.Recording.Valid, Monodromy.Counter.Reversible.Recording.edges, Monodromy.Counter.Reversible.Recording.size, Monodromy.Counter.Reversible.Recording.table, Monodromy.Counter.Reversible.State, Monodromy.Counter.Reversible.step.

Original proof dependencies: Monodromy.Counter.Program, Monodromy.Counter.Reversible.Action, Monodromy.Counter.Reversible.Action.apply, Monodromy.Counter.Reversible.Action.enabled, Monodromy.Counter.Reversible.Edge, Monodromy.Counter.Reversible.Edge.enabled, Monodromy.Counter.Reversible.Edge.execute, Monodromy.Counter.Reversible.Radix.edges, Monodromy.Counter.Reversible.Recording.Arc, Monodromy.Counter.Reversible.Recording.Extra, Monodromy.Counter.Reversible.Recording.Valid, Monodromy.Counter.Reversible.Recording.arcEdge, Monodromy.Counter.Reversible.Recording.arcEquiv, Monodromy.Counter.Reversible.Recording.base, Monodromy.Counter.Reversible.Recording.deterministic, Monodromy.Counter.Reversible.Recording.edges, Monodromy.Counter.Reversible.Recording.extra_valid_edge, Monodromy.Counter.Reversible.Recording.packing_valid_edge, Monodromy.Counter.Reversible.Recording.size, Monodromy.Counter.Reversible.Recording.table, Monodromy.Counter.Reversible.Recording.table_arc, Monodromy.Counter.Reversible.State, Monodromy.Counter.Reversible.StepRel, Monodromy.Counter.Reversible.step, Monodromy.Counter.Reversible.step_iff.

Statement elaboration dependencies: Monodromy.Counter.Program, Monodromy.Counter.Reversible.Recording.Valid, Monodromy.Counter.Reversible.Recording.edges, Monodromy.Counter.Reversible.Recording.size, Monodromy.Counter.Reversible.Recording.table, Monodromy.Counter.Reversible.State, Monodromy.Counter.Reversible.step.

Proof elaboration dependencies: Monodromy.Counter.Program, Monodromy.Counter.Reversible.Action, Monodromy.Counter.Reversible.Action.apply, Monodromy.Counter.Reversible.Action.enabled, Monodromy.Counter.Reversible.Edge, Monodromy.Counter.Reversible.Edge.enabled, Monodromy.Counter.Reversible.Edge.execute, Monodromy.Counter.Reversible.Radix.edges, Monodromy.Counter.Reversible.Recording.Arc, Monodromy.Counter.Reversible.Recording.Extra, Monodromy.Counter.Reversible.Recording.Valid, Monodromy.Counter.Reversible.Recording.arcEdge, Monodromy.Counter.Reversible.Recording.arcEquiv, Monodromy.Counter.Reversible.Recording.base, Monodromy.Counter.Reversible.Recording.deterministic, Monodromy.Counter.Reversible.Recording.edges, Monodromy.Counter.Reversible.Recording.extra_valid_edge, Monodromy.Counter.Reversible.Recording.packing_valid_edge, Monodromy.Counter.Reversible.Recording.size, Monodromy.Counter.Reversible.Recording.table, Monodromy.Counter.Reversible.Recording.table_arc, Monodromy.Counter.Reversible.State, Monodromy.Counter.Reversible.StepRel, Monodromy.Counter.Reversible.step, Monodromy.Counter.Reversible.step_iff.

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.Reversible
open Monodromy.Counter.Reversible.Recording
variable {n m : ℕ}

Formal statement
theorem Monodromy.Counter.Reversible.Recording.valid_step (program : Counter.Program n m) {first last : State (n + 2) (size m)}
    (valid : Valid program first) (transition : step (table program) first = some last) :
    Valid program last := 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.Reversible.Recording.valid_step at L6237-L6253 [UTF-8 311657:312641].
Read-back

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

Let n,m∈Nn,m\in\mathbb Nn,m∈N and let PPP be a natural-counter program with mmm controls and nnn registers, whose instructions are increment-and-jump, zero-test with a nonzero decrement-and-jump, and halt. Put b=2m+1b=2m+1b=2m+1. The recording table TPT_PTP​ uses n+2n+2n+2 integer registers: the original registers, a history register hhh and a workspace register www. For each source row jjj it contains a copy of the reversed graph RbR_bRb​ on (h,w)(h,w)(h,w), with dispatch DjD_jDj​ at that graph's input G0G_0G0​ and port Fj,dF_{j,d}Fj,d​ at its finish Bd,7B_{d,7}Bd,7​; it also has a middle control MjM_jMj​ for every row. A source increment of register iii to row kkk gives an extra edge Dj→Fk,2j+1D_j\to F_{k,2j+1}Dj​→Fk,2j+1​ shifting register iii by +1+1+1. A decrement/test on register iii with zero target kkk and nonzero target lll gives Dj→Fk,2j+1D_j\to F_{k,2j+1}Dj​→Fk,2j+1​ with test i=0i=0i=0, Dj→MjD_j\to M_jDj​→Mj​ with test i≠0i\ne0i=0, and Mj→Fl,2j+2M_j\to F_{l,2j+2}Mj​→Fl,2j+2​ shifting iii by −1-1−1. Halt rows have no extra edges. Copies of the reversed radix edges act only on h,wh,wh,w; reversal swaps endpoints, negates shifts and preserves tests. A table step chooses the least enumerated enabled edge, or has no successor when none is enabled. Write E(s,h)E(s,h)E(s,h) for control Ds.pcD_{s.\mathrm{pc}}Ds.pc​, original registers sis_isi​ coerced to integers, history hhh and workspace 000. For all integer-register states s,ts,ts,t of TPT_PTP​, validity of sss and the equality of its table step to the defined successor ttt imply validity of ttt. This is preservation along any defined step; there is no hypothesis or conclusion asserting that a successor exists at every valid state. A state is valid precisely when all original registers are nonnegative and the following further condition holds: at a copy control corresponding to radix vertex vvv, the history/workspace pair is nonnegative and satisfies the radix admissibility condition at vvv; at middle control MjM_jMj​, history is nonnegative, workspace is 000, the source instruction at jjj is a decrement/test and its tested original register is positive. Radix admissibility on (x,y)(x,y)(x,y) is y=0y=0y=0 at G0G_0G0​, unrestricted at G1G_1G1​, y≠0y\ne0y=0 at G2G_2G2​, and, at phases 0,…,70,\ldots,70,…,7 of Br,∙B_{r,\bullet}Br,∙​, respectively unrestricted, x>0x>0x>0, x=0x=0x=0, unrestricted, y>0y>0y>0, unrestricted, x≠0x\ne0x=0, unrestricted. The two-integer-counter graph RpR_pRp​ has global vertices G0,G1,G2G_0,G_1,G_2G0​,G1​,G2​ and vertices Br,jB_{r,j}Br,j​ for 0≤r<p0\le r<p0≤r<p, 0≤j<80\le j<80≤j<8, with input G0G_0G0​ and finishes Br,7B_{r,7}Br,7​. Its global edges are G0→y=0B0,0G_0\xrightarrow{y=0}B_{0,0}G0​y=0​B0,0​, G1→y↦y+1G2G_1\xrightarrow{y\mapsto y+1}G_2G1​y↦y+1​G2​, G2→y≠0B0,0G_2\xrightarrow{y\ne0}B_{0,0}G2​y=0​B0,0​; for each rrr its other edges are Br,0→x=0Br,2B_{r,0}\xrightarrow{x=0}B_{r,2}Br,0​x=0​Br,2​, Br,0→x≠0Br,1B_{r,0}\xrightarrow{x\ne0}B_{r,1}Br,0​x=0​Br,1​, Br,1→x↦x−1NrB_{r,1}\xrightarrow{x\mapsto x-1}N_rBr,1​x↦x−1​Nr​, Br,2→x=0Br,3B_{r,2}\xrightarrow{x=0}B_{r,3}Br,2​x=0​Br,3​, Br,3→y=0Br,7B_{r,3}\xrightarrow{y=0}B_{r,7}Br,3​y=0​Br,7​, Br,3→y≠0Br,4B_{r,3}\xrightarrow{y\ne0}B_{r,4}Br,3​y=0​Br,4​, Br,4→y↦y−1Br,5B_{r,4}\xrightarrow{y\mapsto y-1}B_{r,5}Br,4​y↦y−1​Br,5​, Br,5→x↦x+1Br,6B_{r,5}\xrightarrow{x\mapsto x+1}B_{r,6}Br,5​x↦x+1​Br,6​ and Br,6→x≠0Br,3B_{r,6}\xrightarrow{x\ne0}B_{r,3}Br,6​x=0​Br,3​, where Nr=Br+1,0N_r=B_{r+1,0}Nr​=Br+1,0​ if r+1<pr+1<pr+1<p and Nr=G1N_r=G_1Nr​=G1​ otherwise. Tests leave the counters unchanged, shifts are unconditionally enabled, and a step takes the least enumerated enabled edge or is undefined if none is enabled.

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