Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

§4.1 — the base-bbb expansion of k/mk/mk/m is strictly periodic with period the order of bbb

Proved
CarryRNG.AWC.expansion_period_iff

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

number-theoryp2o-batch-pfp2bp2o-gran-per-chapterp2o-plan-paperp2o-v1periodic-expansion

Let b≥2b \ge 2b≥2 be a base and m>1m > 1m>1 a modulus with gcd⁡(b,m)=1\gcd(b, m) = 1gcd(b,m)=1, and let kkk be a reduced residue, 0≤k<m0 \le k < m0≤k<m with gcd⁡(k,m)=1\gcd(k, m) = 1gcd(k,m)=1. Write d1,d2,…d_1, d_2, \dotsd1​,d2​,… for the base-bbb digits of k/mk/mk/m after the point, and ord⁡m(b)\operatorname{ord}_m(b)ordm​(b) for the multiplicative order of bbb modulo mmm. Then for every p>0p > 0p>0,

(dj+p=dj for all j≥1)  ⟺  ord⁡m(b)∣p.\bigl(d_{j+p} = d_j \text{ for all } j \ge 1\bigr) \iff \operatorname{ord}_m(b) \mid p .(dj+p​=dj​ for all j≥1)⟺ordm​(b)∣p.

In words: the expansion of k/mk/mk/m is strictly periodic (periodic from the first digit after the point on), and its least period is exactly ord⁡m(b)\operatorname{ord}_m(b)ordm​(b). This is the number-theoretic fact through which the periods of the add-with-carry generators are computed: once the generated digits are identified with those of some k/mk/mk/m, their period is the order of bbb.

Formalization Note The order is orderOf (b : ZMod m). Stating the period as "ppp is a period iff ord⁡m(b)∣p\operatorname{ord}_m(b) \mid pordm​(b)∣p" pins down the least period, rather than only saying that ord⁡m(b)\operatorname{ord}_m(b)ordm​(b) is a period.

Preamble
import Mathlib
import Definitions.Def_CarryRNG_AWC_digit
Formal statement
namespace CarryRNG.AWC

theorem expansion_period_iff (b m k : ℕ) (hb : 2 ≤ b) (hm : 1 < m) (hk : k < m)
    (hkm : Nat.Coprime k m) (hbm : Nat.Coprime b m) (p : ℕ) (hp : 0 < p) :
    (∀ j, 1 ≤ j → digit b m k (j + p) = digit b m k j) ↔ orderOf (b : ZMod m) ∣ p := by sorry

end CarryRNG.AWC
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