Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

§4.3 — generated digits are reversed digits of k/m

Proved
CarryRNG.SWB.output_eq_reversed_digits

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

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

Let b≥2b\ge2b≥2, 0<s<r0<s<r0<s<r, and m=br−bs+1m=b^r-b^s+1m=br−bs+1. Take any Method 1 seed zzz other than (b−1,…,b−1,1)(b-1,\ldots,b-1,1)(b−1,…,b−1,1) and any endpoint C≥r+1C\ge r+1C≥r+1. There is an integer 0≤k<m0\le k<m0≤k<m, positive exactly when zzz is not the all-zero seed, such that the generated block xr+1,…,xCx_{r+1},\ldots,x_Cxr+1​,…,xC​, read backwards, is the opening block of the base-bbb expansion of k/mk/mk/m:

xn=dC+1−n(k/m)(r+1≤n≤C).x_n=d_{C+1-n}(k/m)\qquad(r+1\le n\le C).xn​=dC+1−n​(k/m)(r+1≤n≤C).

Here xnx_nxn​ is the newly appended digit after n−rn-rn−r steps, and djd_jdj​ is the jjjth fractional digit. This precise finite-block form captures the paper’s tableau relation for every seed and every block length; the numerator may depend on CCC.

Preamble
import Definitions.Def_CarryRNG_SWB_out
import Definitions.Def_CarryRNG_AWC_digit
import Definitions.Def_CarryRNG_SWB_modulus
import Definitions.Def_CarryRNG_AWC_zeroSeed
import Definitions.Def_CarryRNG_AWC_topSeed
Formal statement
namespace CarryRNG.SWB

/-- Section 4.3: every generated finite block, read backwards, starts the expansion of
a proper fraction with denominator `m = b^r - b^s + 1`. -/
theorem output_eq_reversed_digits (b : ℕ) (L : CarryRNG.AWC.Lags) (hb : 2 ≤ b)
    (z : CarryRNG.AWC.State b L.r) (hz : z ≠ CarryRNG.AWC.topSeed b L.r hb) (C : ℕ) (hC : L.r + 1 ≤ C) :
    ∃ k : ℕ, k < modulus b L ∧ (0 < k ↔ z ≠ CarryRNG.AWC.zeroSeed b L.r hb) ∧
      ∀ n : ℕ, L.r + 1 ≤ n → n ≤ C →
        out b L hb z n = CarryRNG.AWC.digit b (modulus b L) k (C + 1 - n) := by sorry

end CarryRNG.SWB
Source
G. Marsaglia and A. Zaman, A new class of random number generators, Ann. Appl. Probab. 1 (1991), pp. 470–471, Section 4.3
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