Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

§4.1 — period of the base-b digits of k/m

Proved
CarryRNG.SWB.expansion_period_eq_orderOf

by mikedeng1 · Oct 6, 2026 · Mathlib 0df444a (Lean v4.33.1)

number-theoryp2o-batch-pfp2bp2o-gran-per-chapterp2o-plan-paperp2o-v1periodic-expansionrandom-number-generationsubtract-with-borrow

Let b≥2b\ge2b≥2 and m>1m>1m>1 be integers relatively prime to one another. Let 1≤k<m1\le k<m1≤k<m be relatively prime to mmm, and let djd_jdj​ be the jjjth base-bbb digit of k/mk/mk/m. For every positive integer ppp,

(∀j≥1, dj+p=dj)⟺ord⁡m(b)∣p.\bigl(\forall j\ge1,\ d_{j+p}=d_j\bigr) \quad\Longleftrightarrow\quad \operatorname{ord}_m(b)\mid p.(∀j≥1, dj+p​=dj​)⟺ordm​(b)∣p.

Consequently the least positive digit period is the multiplicative order of bbb modulo mmm. This supplies the number-theoretic period used for the generator.

Preamble
import Definitions.Def_CarryRNG_AWC_digit
Formal statement
namespace CarryRNG.SWB

/-- Section 4.1: the least positive period of the digits of `k/m` is the order of `b` mod `m`. -/
theorem expansion_period_eq_orderOf (b m k p : ℕ) (hb : 2 ≤ b) (hm : 1 < m)
    (hk : 0 < k ∧ k < m) (hkm : Nat.Coprime k m) (hbm : Nat.Coprime b m)
    (hp : 0 < p) :
    (∀ j : ℕ, 1 ≤ j → CarryRNG.AWC.digit b m k (j + p) = CarryRNG.AWC.digit b m k j) ↔
      orderOf (b : ZMod m) ∣ p := by sorry

end CarryRNG.SWB
Source
G. Marsaglia and A. Zaman, A new class of random number generators, Ann. Appl. Probab. 1 (1991), p. 467, Section 4.1
Human review
  • Endorsed by Shuze Chen · Oct 6, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Oct 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