Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Division consumption accumulates quotient and control remainder

Proved
Monodromy.Counter.DivMod.consume_reaches

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

computabilitycovering-spacesmonodromy-computation

For every positive divisor p, natural counter values x,y, and remainder r with 0≤r<p, the finite division program runs from its consume(r) address with counters (x,y) to transfer((x+r) mod p) with counters (0,y+⌊(x+r)/p⌋). The remainder is retained in finite control, and the conclusion is finite reachability rather than termination at that transfer address.

Statement dependencies: Monodromy.Counter.Configuration, Monodromy.Counter.DivMod.configuration, Monodromy.Counter.DivMod.consume, Monodromy.Counter.DivMod.program, Monodromy.Counter.DivMod.residue, Monodromy.Counter.DivMod.size, Monodromy.Counter.DivMod.transfer, Monodromy.Counter.step.

Original proof dependencies: Monodromy.Counter.Configuration, Monodromy.Counter.DivMod.bump, Monodromy.Counter.DivMod.configuration, Monodromy.Counter.DivMod.consume, Monodromy.Counter.DivMod.next, Monodromy.Counter.DivMod.prepend, Monodromy.Counter.DivMod.program, Monodromy.Counter.DivMod.reaches_step, Monodromy.Counter.DivMod.residue, Monodromy.Counter.DivMod.residue_small, Monodromy.Counter.DivMod.size, Monodromy.Counter.DivMod.step_bump, Monodromy.Counter.DivMod.step_consume_succ, Monodromy.Counter.DivMod.step_consume_zero, Monodromy.Counter.DivMod.transfer, Monodromy.Counter.step.

Statement elaboration dependencies: Monodromy.Counter.Configuration, Monodromy.Counter.DivMod.configuration, Monodromy.Counter.DivMod.consume, Monodromy.Counter.DivMod.program, Monodromy.Counter.DivMod.residue, Monodromy.Counter.DivMod.size, Monodromy.Counter.DivMod.transfer, Monodromy.Counter.step.

Proof elaboration dependencies: Monodromy.Counter.Configuration, Monodromy.Counter.DivMod.bump, Monodromy.Counter.DivMod.configuration, Monodromy.Counter.DivMod.consume, Monodromy.Counter.DivMod.next, Monodromy.Counter.DivMod.prepend, Monodromy.Counter.DivMod.program, Monodromy.Counter.DivMod.reaches_step, Monodromy.Counter.DivMod.residue, Monodromy.Counter.DivMod.residue_small, Monodromy.Counter.DivMod.size, Monodromy.Counter.DivMod.step_bump, Monodromy.Counter.DivMod.step_consume_succ, Monodromy.Counter.DivMod.step_consume_zero, Monodromy.Counter.DivMod.transfer, Monodromy.Counter.step.

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.DivMod
variable (p : ℕ) [NeZero p]

Formal statement
theorem Monodromy.Counter.DivMod.consume_reaches (first second : ℕ) (remainder : Fin p) :
    StateTransition.Reaches (Counter.step (program p))
      (configuration p (consume p remainder) first second)
      (configuration p (transfer p (residue p (first + remainder.val))) 0
        (second + (first + remainder.val) / p)) := 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.DivMod.consume_reaches at L1181-L1216 [UTF-8 55527:57724].
Read-back

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

For every positive natural ppp, natural numbers x,yx,yx,y and remainder r∈{0,…,p−1}r\in\{0,\ldots,p-1\}r∈{0,…,p−1}, there is a finite, possibly zero-length, sequence of defined steps of the following two-natural-counter program from control rrr with counters (x,y)(x,y)(x,y) to control p+((x+r) mod p)p+((x+r)\bmod p)p+((x+r)modp) with counters (0,y+⌊(x+r)/p⌋)(0,y+\lfloor(x+r)/p\rfloor)(0,y+⌊(x+r)/p⌋). Its 4p+14p+14p+1 control positions are consumption rrr, transfer p+rp+rp+r, restore 2p+r2p+r2p+r, finish 3p+r3p+r3p+r for each remainder, and bump 4p4p4p. At consumption rrr, register 000 is tested/decremented: zero jumps to transfer rrr; nonzero decrements and jumps to consumption r+1r+1r+1 if r+1<pr+1<pr+1<p, otherwise bump. At transfer rrr, register 111 is tested/decremented: zero jumps to finish rrr, nonzero decrements and jumps to restore rrr; restore increments register 000 and returns to transfer rrr; finish halts; bump increments register 111 and returns to consumption 000. No initial positivity of xxx or yyy is assumed, p=1p=1p=1 is allowed, and quotient and remainder are natural-number division and modulus by the nonzero ppp.

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