Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

The greedy carry of Erdős 261 is the map (N,R)↦(N+1, 2R mod (N+1))(N,R)\mapsto(N+1,\,2R \bmod (N+1))(N,R)↦(N+1,2Rmod(N+1))

Proved
Erdos261.greedy_eq_step_mod

by Ethan Cheung Wang · Oct 23, 2026 · Mathlib 0df444a (Lean v4.33.1)

erdos-problemsnumber-theory

Let gjg_jgj​ be the greedy carry for Erdős Problem 261 started at (n,n)(n,n)(n,n): g0=ng_0=ng0​=n, and gj+1=2gj−(n+j+1)g_{j+1}=2g_j-(n+j+1)gj+1​=2gj​−(n+j+1) if 2gj≥n+j+12g_j\ge n+j+12gj​≥n+j+1 (a subtracting step, the term (n+j+1)/2n+j+1(n+j+1)/2^{n+j+1}(n+j+1)/2n+j+1 is used), otherwise gj+1=2gjg_{j+1}=2g_jgj+1​=2gj​ (a doubling step). Then gj/2n+jg_j/2^{n+j}gj​/2n+j is what remains of n/2nn/2^nn/2n after the terms used so far, and the greedy algorithm terminates iff some gj=0g_j=0gj​=0. Theorem. For all n,j≥0n,j\ge0n,j≥0, the jjj-th iterate of T(N,R)=(N+1, 2R mod (N+1))T(N,R)=(N+1,\,2R\bmod (N+1))T(N,R)=(N+1,2Rmod(N+1)) from (n,n)(n,n)(n,n) is (n+j, gj)(n+j,\,g_j)(n+j,gj​).

So the greedy algorithm is exactly the Borwein–Loring iteration ak+1=2(ak mod k)a_{k+1}=2(a_k\bmod k)ak+1​=2(ak​modk) (with a=2Ra=2Ra=2R), with no off-by-one: one uses 0≤gj≤n+j0\le g_j\le n+j0≤gj​≤n+j throughout.

Formalization Note. gjg_jgj​ is an integer (greedy n j : ℤ), and the statement uses (greedy n j).toNat; it is nonnegative.

Preamble
import Mathlib
import Definitions.Def_Erdos261_defs
open Finset
Formal statement
namespace Erdos261

theorem greedy_eq_step_mod (n j : ℕ) :
    (fun p : ℕ × ℕ => (p.1 + 1, (2 * p.2) % (p.1 + 1)))^[j] (n, n) = (n + j, (greedy n j).toNat) := by sorry

end Erdos261
Source
Erdős Problem 261 (https://www.erdosproblems.com/261); greedy carry as in Borwein–Loring 1990 / Tengely–Ulas–Zygadło 2020 (platform def Def_Erdos261_defs); identification checked for GPT 6.1 Sol's step map; claim from GPT 6.1 Sol (second answer, Oct 23 2026), Lean-verified by Grok Bot for Ethan Cheung (Oct 23 2026)

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 paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me