{
  "id": "6059",
  "ident": "NS.06059",
  "slug": "oeis-271591",
  "title": "Maximal run lengths in the second MSB of Tribonacci numbers $T(n)$",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "It is conjectured that after the first two 0's, the number of consecutive 0's is only 4 or 5, and the number of consecutive 1's is only 3 or 4 (tested up to $n = 10^4$).\n\nA formal proof has been found with the methods described in\n[arxiv/2605.22763](https://arxiv.org/abs/2605.22763).",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [
    "formal_proof"
  ],
  "collection": "oeis",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "OeisA271591.maximal_run_lengths",
  "statement_lean": "theorem maximal_run_lengths : (∀ n L, IsMaximalRun 0 n L → (L = 4 ∨ L = 5)) ∧\n    (∀ n L, IsMaximalRun 1 n L → (L = 3 ∨ L = 4))",
  "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-/\nmodule\n\npublic import FormalConjecturesUtil\n\n/-!\n# Maximal run lengths in the second MSB of Tribonacci numbers $T(n)$\n\nThe Tribonacci numbers $T_n$ (A000073).\n$T_0=0, T_1=0, T_2=1$, and $T_n = T_{n-1} + T_{n-2} + T_{n-3}$ for $n \\ge 3$.\n\nSecond most significant bit of the tribonacci number A000073(n).\nThis is formalized by extracting the bit at position $\\lfloor \\log_2 T_n \\rfloor - 1$.\n\n*References:*\n- [A271591](https://oeis.org/A271591)\n- [arxiv/2605.22763](https://arxiv.org/abs/2605.22763) *Advancing Mathematics Research with AI-Driven Formal Proof Search* by George Tsoukalas et al.\n- [A000073](https://oeis.org/A000073)\n-/\n\n@[expose] public section\n\nnamespace OeisA271591\n\n\nopen Nat\n\n/--\nThe Tribonacci numbers $T_n$ (A000073).\n$T_0=0, T_1=0, T_2=1$, and $T_n = T_{n-1} + T_{n-2} + T_{n-3}$ for $n \\ge 3$.\n-/\ndef tribonacci (n : ℕ) : ℕ :=\n  match n with\n  | 0 => 0\n  | 1 => 0\n  | 2 => 1\n  | n + 3 => (tribonacci (n + 2)) + (tribonacci (n + 1)) + (tribonacci n)\n\n/--\nSecond most significant bit of the tribonacci number A000073(n).\nThis is formalized by extracting the bit at position $\\lfloor \\log_2 T_n \\rfloor - 1$.\n-/\ndef a (n : ℕ) : ℕ :=\n  let T := tribonacci n\n  -- The index of the MSB is T.log2. The index of the second MSB is T.log2 - 1.\n  if T ≤ 1 then\n    0\n  else\n    let j_smsb : ℕ := T.log2 - 1\n    if T.testBit j_smsb then 1 else 0\n\ndef IsMaximalRun (v : ℕ) (n L : ℕ) : Prop :=\n  n ≥ 2 ∧ L ≥ 1 ∧\n  -- The run consists of L consecutive $v$'s starting at n\n  (∀ i : ℕ, i < L → a (n + i) = v) ∧\n  -- The run is not followed by $v$\n  (a (n + L) ≠ v) ∧\n  -- The run is not preceded by $v$\n  (a (n - 1) ≠ v)\n\n\n@[category test, AMS 11]\nlemma a_4 : a 4 = 0 := by rfl\n\n@[category test, AMS 11]\nlemma a_5 : a 5 = 0 := by rfl\n\n@[category test, AMS 11]\nlemma a_6 : a 6 = 1 := by rfl\n\n@[category test, AMS 11]\nlemma a_7 : a 7 = 1 := by rfl\n\n@[category test, AMS 11]\nlemma a_8 : a 8 = 1 := by rfl\n\n\nset_option linter.style.formal_proof_palomar false in\n/--\nIt is conjectured that after the first two 0's, the number of consecutive 0's is only 4 or 5, and the number of consecutive 1's is only 3 or 4 (tested up to $n = 10^4$).\n\nA formal proof has been found with the methods described in\n[arxiv/2605.22763](https://arxiv.org/abs/2605.22763).\n-/\n@[category research solved, AMS 11, formal_proof using formal_conjectures at\n\"https://github.com/mo271/formal-conjectures/blob/a32396489dcb8f86c3549b93aa358ac6a10a3a1f/FormalConjectures/OEIS/271591.wip.lean#L497\"]\ntheorem maximal_run_lengths : (∀ n L, IsMaximalRun 0 n L → (L = 4 ∨ L = 5)) ∧\n    (∀ n L, IsMaximalRun 1 n L → (L = 3 ∨ L = 4)) := by\n    sorry\n\nend OeisA271591\n",
  "statement_hash": "68778a6481909f875ab0407945cd4b04c18676f6aa05e2b8dc5007032bcc7353",
  "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."
}