Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

§2, p. 465 — the generator xn=xn−2+xn−1+c mod 10x_n = x_{n-2} + x_{n-1} + c \bmod 10xn​=xn−2​+xn−1​+cmod10 has period 108

Proved
CarryRNG.AWC.example_base10_period

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

add-with-carryp2o-batch-pfp2bp2o-gran-per-chapterp2o-plan-paperp2o-v1random-number-generation

Take base b=10b = 10b=10 and lags r=2r = 2r=2, s=1s = 1s=1, so that the add-with-carry map is

f(x1,x2,c)={(x2, x1+x2+c, 0)if x1+x2+c<10,(x2, x1+x2+c−10, 1)if x1+x2+c≥10.f(x_1, x_2, c) = \begin{cases} (x_2,\ x_1 + x_2 + c,\ 0) & \text{if } x_1 + x_2 + c < 10,\\ (x_2,\ x_1 + x_2 + c - 10,\ 1) & \text{if } x_1 + x_2 + c \ge 10. \end{cases}f(x1​,x2​,c)={(x2​, x1​+x2​+c, 0)(x2​, x1​+x2​+c−10, 1)​if x1​+x2​+c<10,if x1​+x2​+c≥10.​
  1. If the seed is x=(x1,x2,0)x = (x_1, x_2, 0)x=(x1​,x2​,0) with x1<x2x_1 < x_2x1​<x2​, or x=(x1,x2,1)x = (x_1, x_2, 1)x=(x1​,x2​,1) with x1>x2x_1 > x_2x1​>x2​, then the sequence x,f(x),f2(x),…x, f(x), f^2(x), \dotsx,f(x),f2(x),… is strictly periodic with least period 108108108.
  2. If the seed xxx is of neither type and is not one of the trivial seeds (0,0,0)(0, 0, 0)(0,0,0) and (9,9,1)(9, 9, 1)(9,9,1), then the sequence beginning with f(x)f(x)f(x) is strictly periodic with least period 108108108.

Here m=102+10−1=109m = 10^2 + 10 - 1 = 109m=102+10−1=109 is prime and 108108108 is the order of 101010 modulo 109109109; the statement is a concrete instance of the general period theorem of the mission.

Formalization Note The paper prints the second trivial seed as "(9,9,9)(9, 9, 9)(9,9,9)"; the third entry is the carry bit, so the seed meant is (9,9,1)(9, 9, 1)(9,9,1), the trivial seed (b−1,b−1,1)(b-1, b-1, 1)(b−1,b−1,1) of p. 472. "Period 108" is stated as Function.minimalPeriod f _ = 108.

Preamble
import Mathlib
import Definitions.Def_CarryRNG_AWC_step
import Definitions.Def_CarryRNG_AWC_zeroSeed
import Definitions.Def_CarryRNG_AWC_topSeed
Formal statement
namespace CarryRNG.AWC

theorem example_base10_period :
    let L : Lags := ⟨2, 1, by norm_num, by norm_num⟩
    (∀ z : State 10 L.r,
        (z.c = 0 ∧ z.x 0 < z.x 1) ∨ (z.c = 1 ∧ z.x 1 < z.x 0) →
        Function.minimalPeriod (step 10 L) z = 108) ∧
    (∀ z : State 10 L.r,
        ¬ ((z.c = 0 ∧ z.x 0 < z.x 1) ∨ (z.c = 1 ∧ z.x 1 < z.x 0)) →
        z ≠ zeroSeed 10 L.r (by norm_num) → z ≠ topSeed 10 L.r (by norm_num) →
        Function.minimalPeriod (step 10 L) (step 10 L z) = 108) := by sorry

end CarryRNG.AWC
Source
G. Marsaglia and A. Zaman, A new class of random number generators, Ann. Appl. Probab. 1 (1991), p. 465, Section 2
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