{
  "id": "6053",
  "ident": "NS.06053",
  "slug": "oeis-267581",
  "title": "Recurrence for Rule 167 cellular automaton sequence",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "Conjecture: $a(n) = 2 a(n-1) + 1 - \\lfloor (1/2)^{2^{n+1} \\bmod n} \\rfloor$ for $n \\ge 2$. - _Andres Cicuttin_, Mar 29 2016\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": "OeisA267581.a_recurrence",
  "statement_lean": "theorem a_recurrence (n : ℕ) (hn : 2 ≤ n) : a n = 2 * a (n - 1) + 1 - oeisFloorTerm n",
  "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# Recurrence for Rule 167 cellular automaton sequence\n\nDecimal representation of the middle column of the \"Rule 167\" elementary cellular automaton\nstarting with a single ON (black) cell.\n\n*References:*\n- [A267581](https://oeis.org/A267581)\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-/\n\n@[expose] public section\n\nnamespace OeisA267581\n\n\nopen Nat Int\n\n/-- The rule function for Rule 167. Inputs must be 0 or 1. -/\ndef caRule167 (c_L c_C c_R : ℕ) : ℕ :=\n  let R : ℕ := 167\n  let index : ℕ := 4 * c_L + 2 * c_C + c_R\n  -- Rule 167 is determined by the index-th bit of R.\n  (R / (2 ^ index)) % 2\n\n/--\nThe state of the Rule 167 elementary cellular automaton at time $t$ and position $x$.\nThe initial condition is a single ON cell at $x=0$.\n$C(t, x)$ is structurally recursive on $t$.\n-/\ndef caState (t : ℕ) (x : ℤ) : ℕ :=\n  match t with\n  | 0 => if x = 0 then 1 else 0\n  | t' + 1 =>\n    let C_t' (y : ℤ) := caState t' y\n    caRule167 (C_t' (x - 1)) (C_t' x) (C_t' (x + 1))\n\n/-- The sequence of bits forming the middle column of the CA pattern, $C_{t, 0}$. -/\ndef middleColumnBit (t : ℕ) : ℕ := caState t 0\n\n/--\nDecimal representation of the middle column of the \"Rule 167\" elementary cellular automaton\nstarting with a single ON (black) cell.\nThe term $a(n)$ is the decimal value of the binary number $C_{0, 0} C_{1, 0} \\dots C_{n, 0}$,\nwhere $C_{i, 0}$ is the state of the center cell at time $i$.\n$$a(n) = \\sum_{k=0}^n C_{k, 0} \\cdot 2^{n-k}$$\n-/\ndef a (n : ℕ) : ℕ :=\n  Finset.sum (Finset.range (n + 1)) fun k => (middleColumnBit k) * (2^ (n - k))\n\n/-- The floor term in the conjectured recurrence relation for A267581.\nThis term, $\\lfloor (1/2)^{(2^{n+1} \\bmod n)} \\rfloor$, simplifies to 1 if $(2^{n+1} \\bmod n) = 0$\n(i.e., $n \\mid 2^{n+1}$), and 0 otherwise.\nSince the recurrence is only stated for $n \\ge 2$, the $n=0$ case is irrelevant\nto the conjecture. -/\ndef oeisFloorTerm (n : ℕ) : ℕ :=\n  if n = 0 then 0\n  else if (2 ^ (n + 1)) % n = 0 then 1 else 0\n\n\n@[category test, AMS 11]\nlemma a_0 : a 0 = 1 := by rfl\n\n@[category test, AMS 11]\nlemma a_1 : a 1 = 3 := by rfl\n\n@[category test, AMS 11]\nlemma a_2 : a 2 = 6 := by rfl\n\n@[category test, AMS 11]\nlemma a_3 : a 3 = 13 := by rfl\n\n@[category test, AMS 11]\nlemma a_4 : a 4 = 26 := by rfl\n\n\nset_option linter.style.formal_proof_palomar false in\n/--\nConjecture: $a(n) = 2 a(n-1) + 1 - \\lfloor (1/2)^{2^{n+1} \\bmod n} \\rfloor$ for $n \\ge 2$. - _Andres Cicuttin_, Mar 29 2016\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/267581.wip.lean#L190\"]\ntheorem a_recurrence (n : ℕ) (hn : 2 ≤ n) : a n = 2 * a (n - 1) + 1 - oeisFloorTerm n := by\n    sorry\n\nend OeisA267581\n",
  "statement_hash": "0cc503dea2b6d4c71c656afd97393ec818178420d4227d507699e88abaef927d",
  "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."
}