{
  "id": "2245",
  "ident": "NS.02245",
  "slug": "erdos-482",
  "title": "Erdős Problem 482",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "Define a sequence by $a_1=1$ and $$a_{n+1}=\\lfloor\\sqrt{2}(a_n+1/2)\\rfloor$$ for $n\\geq 1$.\nThe difference $a_{2n+1}-2a_{2n-1}$ is the $n$th digit in the binary expansion of $\\sqrt{2}$.\n\nFind similar results for $\\theta=\\sqrt{m}$, and other algebraic numbers.\n\nThe result for $\\sqrt{2}$ was obtained by Graham and Pollak [GrPo70]. The problem statement is\nopen-ended, but presumably Erdős and Graham would have been satisfied with the wide-ranging\ngeneralisations of Stoll ([St05] and [St06]).\n\nThe binary expansion is $\\sqrt{2} = 1.0110101\\ldots$, and the $n$th digit counts the leading $1$ as\ndigit $1$.  It is stated with Mathlib's `Real.digits`: the $n$th digit of $\\sqrt{2}$ is digit $n - 1$\nof $\\sqrt{2}/2 = 0.10110101\\ldots$, that is $\\lfloor \\sqrt{2} \\cdot 2^{n-1} \\rfloor \\bmod 2$.  The\nsecond conjunct records that these digits are the binary expansion: they reconstruct $\\sqrt{2}/2$.",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [
    "formal_proof"
  ],
  "collection": "erdos",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Erdos482.erdos_482",
  "statement_lean": "theorem erdos_482 :\n    (∀ n : ℕ, 1 ≤ n →\n      (a (2 * n + 1) : ℤ) - 2 * a (2 * n - 1) = (Real.digits (√2 / 2) 2 (n - 1) : ℕ)) ∧\n      Real.ofDigits (Real.digits (√2 / 2) 2) = √2 / 2",
  "challenge_source": "/-\nCopyright 2026 The Formal Conjectures Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-/\n\nmodule\n\npublic import FormalConjecturesUtil\n\n/-!\n# Erdős Problem 482\n\n*References:*\n- [erdosproblems.com/482](https://www.erdosproblems.com/482)\n- [GrPo70] Graham, R. L. and Pollak, H. O., Note on a nonlinear recurrence related to {$\\surd 2$}. Math. Mag. (1970), 143-145.\n- [St05] Stoll, Th., On families of nonlinear recurrences related to digits. J. Integer Seq. (2005), Article 05.3.2, 8.\n- [St06] Stoll, Thomas, On a problem of Erd\\H{o}s and Graham concerning digits. Acta Arith. (2006), 89-100.\n- [RaGi91] Rabinowitz, S. and Gilbert, P., A nonlinear recurrence yielding binary digits. Math. Mag.\n  64 (1991), 168-171.\n\nA formal Lean proof is given in an external repository,\n[`gotrevor/lean-gallery`](https://github.com/gotrevor/lean-gallery), formalized by Trevor Morris with\nClaude Code.\n-/\n\n@[expose] public section\n\nnamespace Erdos482\n\n/-- The sequence of the problem: $a_1 = 1$ and $a_{n+1} = \\lfloor \\sqrt{2}(a_n + 1/2) \\rfloor$ for\n$n \\geq 1$. The value $a_0$ is not used. -/\nnoncomputable def a : ℕ → ℕ\n  | 0 => 0\n  | 1 => 1\n  | n + 2 => ⌊√2 * ((a (n + 1) : ℝ) + 1 / 2)⌋₊\n\n/-- Stoll's general Graham–Pollak-type recurrence in base $g$, with real parameters $a$, $b$, and\n$\\varepsilon$. Its even-index differences are used to read base-$g$ digits. -/\nnoncomputable def generalRecurrence (g : ℕ) (a b ε : ℝ) : ℕ → ℤ\n  | 0 => 1\n  | n + 1 =>\n      if Even n then ⌊a * ((generalRecurrence g a b ε n : ℝ) + ε)⌋\n      else ⌊b * ((generalRecurrence g a b ε n : ℝ) + 1 / ((g : ℝ) - 1))⌋\n\nset_option linter.style.formal_proof_palomar false in\n/-- Define a sequence by $a_1=1$ and $$a_{n+1}=\\lfloor\\sqrt{2}(a_n+1/2)\\rfloor$$ for $n\\geq 1$.\nThe difference $a_{2n+1}-2a_{2n-1}$ is the $n$th digit in the binary expansion of $\\sqrt{2}$.\n\nFind similar results for $\\theta=\\sqrt{m}$, and other algebraic numbers.\n\nThe result for $\\sqrt{2}$ was obtained by Graham and Pollak [GrPo70]. The problem statement is\nopen-ended, but presumably Erdős and Graham would have been satisfied with the wide-ranging\ngeneralisations of Stoll ([St05] and [St06]).\n\nThe binary expansion is $\\sqrt{2} = 1.0110101\\ldots$, and the $n$th digit counts the leading $1$ as\ndigit $1$.  It is stated with Mathlib's `Real.digits`: the $n$th digit of $\\sqrt{2}$ is digit $n - 1$\nof $\\sqrt{2}/2 = 0.10110101\\ldots$, that is $\\lfloor \\sqrt{2} \\cdot 2^{n-1} \\rfloor \\bmod 2$.  The\nsecond conjunct records that these digits are the binary expansion: they reconstruct $\\sqrt{2}/2$. -/\n@[category research solved, AMS 11,\n  formal_proof using lean4 at\n    \"https://github.com/gotrevor/lean-gallery/blob/a28a487968d989b24c9dde9b1958aa5b92c6fccb/LeanGallery/NumberTheory/Erdos482/Statement.lean#L46-L49\"]\ntheorem erdos_482 :\n    (∀ n : ℕ, 1 ≤ n →\n      (a (2 * n + 1) : ℤ) - 2 * a (2 * n - 1) = (Real.digits (√2 / 2) 2 (n - 1) : ℕ)) ∧\n      Real.ofDigits (Real.digits (√2 / 2) 2) = √2 / 2 := by\n  sorry\n\nset_option linter.style.formal_proof_palomar false in\n/-- Stoll's general answer to the open-ended part [St05]: for every real $w > 0$ and every base\n$g \\ge 2$, there are parameters $a$, $b$, and $\\varepsilon$, with $ab = g$, such that the\ncorresponding Graham–Pollak-type recurrence reads the base-$g$ digits of $w$.\n\nThe mantissa normalization is $w / g^{\\lfloor \\log_g w \\rfloor}$, so the right-hand side is the\nstandard Mathlib base-$g$ digit of the normalized expansion. -/\n@[category research solved, AMS 11,\n  formal_proof using lean4 at\n    \"https://github.com/gotrevor/lean-gallery/blob/a834bbad2f36eedcc16066b2bc4da49f98ab5b85/LeanGallery/NumberTheory/Erdos482/Statement.lean#L64-L67\"]\ntheorem erdos_482.variants.stoll_general (g : ℕ) [NeZero g] (hg : 2 ≤ g) (w : ℝ) (hw : 0 < w) :\n    ∃ a b ε : ℝ, a * b = g ∧\n      ∀ n : ℕ, 1 ≤ n →\n        generalRecurrence g a b ε (2 * n) - g * generalRecurrence g a b ε (2 * n - 2) =\n          (Real.digits (w / (g : ℝ) ^ ⌊Real.logb g w⌋ * (g : ℝ) ^ (n - 1) / g) g 0 : ℕ) := by\n  sorry\n\n/-- The odd-step coefficient of the Rabinowitz–Gilbert/Stoll binary recurrence. -/\nnoncomputable def alpha (t : ℝ) : ℝ := 2 * (t + 1) / (t + 2)\n\n/-- The even-step coefficient of the Rabinowitz–Gilbert/Stoll binary recurrence. -/\nnoncomputable def beta (t : ℝ) : ℝ := (t + 2) / (t + 1)\n\n/-- Zero-based form of the Rabinowitz–Gilbert/Stoll binary recurrence: `stollBinary t k` is the\npaper's $u_{k+1}$.  At $t = \\sqrt{2}$ both coefficients equal $\\sqrt{2}$, and this is the sequence\n`a` shifted by one. -/\nnoncomputable def stollBinary (t : ℝ) : ℕ → ℕ\n  | 0 => 1\n  | n + 1 =>\n      ⌊(if Even n then alpha t else beta t) * ((stollBinary t n : ℝ) + 1 / 2)⌋₊\n\n/-- The binary digits of a normalized real $t \\in [1, 2)$, indexed from one and including the\nleading digit.  The value at index zero is padding. -/\nnoncomputable def binaryDigit (t : ℝ) : ℕ → Fin 2\n  | 0 => 0\n  | 1 => 1\n  | k + 2 => Real.digits (t - 1) 2 k\n\nset_option linter.style.formal_proof_palomar false in\n/-- The explicit binary answer to the open-ended part [RaGi91], [St05]: for every normalized real\n$t \\in [1, 2)$, the recurrence with coefficients $\\alpha(t) = 2(t+1)/(t+2)$ and\n$\\beta(t) = (t+2)/(t+1)$ reads off the binary digits of $t$, and those digits reconstruct $t$.\nUnlike `erdos_482.variants.stoll_general`, the coefficients are given, not merely shown to exist. -/\n@[category research solved, AMS 11,\n  formal_proof using lean4 at\n    \"https://github.com/plby/lean-proofs/blob/33a6b9a285cb64ac276ce4d0b3a4111b82c972b6/src/latest/ErdosProblems/Erdos482.lean#L323-L332\"]\ntheorem erdos_482.variants.binary_explicit (t : ℝ) (ht1 : 1 ≤ t) (ht2 : t < 2) :\n    (∀ n, 1 ≤ n →\n        stollBinary t (2 * n) - 2 * stollBinary t (2 * n - 2) = (binaryDigit t n).val) ∧\n      Real.ofDigits (fun k ↦ binaryDigit t (k + 2)) = t - 1 := by\n  sorry\n\n/-- The explicit base-$g$ construction in Stoll [St05, Theorem 1.3]. For a normalized\n$t \\in [1,g)$, take $a = g/((g-1)(t+g))$ and $b = (g-1)(t+g)$. Every parameter\n$-1/g \\le \\varepsilon < (g+1)(g-2)/g$ gives the same significant digits of $t$.\n\nThe sequence is indexed from zero, so the difference at $2n+2$ and $2n$ gives digit $n$,\nincluding the leading digit at $n=0$. The floor difference uses the terminating expansion\nwhen $t$ has two base-$g$ expansions. -/\n@[category research solved, AMS 11]\ntheorem erdos_482.variants.stoll_explicit (g : ℕ) (hg : 2 ≤ g) (t : ℝ)\n    (ht : 1 ≤ t) (htg : t < g) (ε : ℝ)\n    (hεlo : -1 / (g : ℝ) ≤ ε)\n    (hεhi : ε < ((g : ℝ) + 1) * ((g : ℝ) - 2) / g) :\n    let a := (g : ℝ) / (((g : ℝ) - 1) * (t + g))\n    let b := ((g : ℝ) - 1) * (t + g)\n    ∀ n : ℕ,\n      generalRecurrence g a b ε (2 * n + 2) -\n          (g : ℤ) * generalRecurrence g a b ε (2 * n) =\n        ⌊t * (g : ℝ) ^ n⌋ - (g : ℤ) * ⌊t * (g : ℝ) ^ n / g⌋ := by\n  sorry\n\nend Erdos482\n",
  "statement_hash": "68a3b9e85d906cf359ae92a460a2dad9ff3123dc3c1f71a99ca1496634719f40",
  "toolchain": "leanprover/lean4:v4.33.1",
  "upstream_commit": "f9b3868d5ca994a7bf95039bcec05338c0c21e2f",
  "workspace": "formal-conjectures",
  "field": "math",
  "formalization": "formal",
  "verification": "lean-kernel",
  "license": "Apache-2.0",
  "attribution": "google-deepmind/formal-conjectures contributors",
  "metric_name": null,
  "metric_direction": null,
  "critiques": [],
  "public_partial_proofs": [],
  "research_threads": [],
  "instructions": "Read research_threads first: other people's public repositories and what they already tried. Write Solution.lean starting from challenge_source. Keep every definition identical, prove decl_name with exactly the same type, no sorry in its dependency closure, no new axioms, no native_decide, no metaprogramming. Submit with POST /api/v1/submissions."
}