{
  "id": "4725",
  "ident": "NS.04725",
  "slug": "oeis-112970",
  "title": "A generalized Stern sequence",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "Conjecture: $a(2^n)=a(2^(n+1)+1)=\\textrm{A033638}(n)$.\nThis formalizes the equality $a(2^n) = a(2^(n+1)+1)$.",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [
    "formal_proof"
  ],
  "collection": "oeis",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "OeisA112970.conjecture1",
  "statement_lean": "theorem conjecture1 (n : ℕ) : a (2^n) = a (2^(n + 1) + 1)",
  "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# A generalized Stern sequence\n\nA112970: A generalized Stern sequence, defined by the recurrence relations:\n$a(2n+1) = a(n)$ and $a(2n) = a(n) + a(n-2)$ with $a(0)=1$, $a(1)=1$ and $a(n)=0$ for $n \\le -1$.\n\n*References:*\n- [A112970](https://oeis.org/A112970)\n-/\n\n@[expose] public section\n\nnamespace OeisA112970\n\n/--\na n is the generalized Stern sequence, defined by the recurrence relations:\n$a(2n+1) = a(n)$ and $a(2n) = a(n)$ + $a(n-2)$ with $a(0) = 1$, $a(1) = 1$\nand $a(n) = 0$ for $n \\le -1$.\n-/\ndef a (n : ℕ) : ℕ :=\n  if n = 0 then 1\n  else if n = 1 then 1\n  else\n    let k := n / 2\n    if n % 2 = 1 then -- Odd case: a(2k + 1) = a(k)\n      a k\n    else -- Even case: a(2k) = a(k) + a(k - 2)\n      let aPrev : ℕ :=\n        -- a(m) is 0 if m < 0. Equivalent to checking k < 2 for the argument k-2.\n        if k < 2 then 0\n        else a (k - 2)\n      a k + aPrev\ntermination_by n\n\n@[category test, AMS 11]\ntheorem a_0 : a 0 = 1 := by unfold a; rfl\n\n@[category test, AMS 11]\ntheorem a_1 : a 1 = 1 := by unfold a; rfl\n\n@[category test, AMS 11]\ntheorem a_2 : a 2 = 1 := by unfold a; unfold a; unfold a; rfl\n\n@[category test, AMS 11]\ntheorem a_3 : a 3 = 1 := by unfold a; unfold a; rfl\n\n@[category test, AMS 11]\ntheorem a_4 : a 4 = 2 := by unfold a; unfold a; unfold a; unfold a; rfl\n\nset_option linter.style.formal_proof_palomar false in\n/--\nConjecture: $a(2^n)=a(2^(n+1)+1)=\\textrm{A033638}(n)$.\nThis formalizes the equality $a(2^n) = a(2^(n+1)+1)$.\n-/\n@[category research solved, AMS 11,\n  formal_proof using lean4 at\n    \"https://github.com/KitaKen1/oeis-a112970-formal-conjectures/blob/71ae72f443bd9bee7d958f0a19d9f9ec5ab82af5/lean/OeisA112970FC.lean#L43-L46\"]\ntheorem conjecture1 (n : ℕ) : a (2^n) = a (2^(n + 1) + 1) := by\n  sorry\n\nset_option linter.style.formal_proof_palomar false in\n/--\nSecond part of the conjecture, $a(2^n)=\\textrm{A033638}(n)=\\lfloor n^2 / 4 \\rfloor + 1$.\nIt holds by induction on $n$, since $a(2^{n+1}) = a(2^n) + a(2^n - 2)$ for $n \\ge 1$ and\n$a(2^m - 2) = \\lfloor (m+1)/2 \\rfloor$ for $m \\ge 1$.\n-/\n@[category research solved, AMS 11, formal_proof using lean4 at \"https://github.com/anatoliiohorodnyk/lean-fc-proofs/blob/5da9642575b26c2c816a49bcb56b33fed5456619/Proofs/T_OeisA112970_conjecture1_value.lean#L139\"]\ntheorem conjecture1_value (n : ℕ) : a (2^n) = n ^ 2 / 4 + 1 := by\n  sorry\n\nset_option linter.style.formal_proof_palomar false in\n/--\nConjecture: $a(2^n-1)=a(3*2^n-1)=1$.\nThis formalizes the equality part $a(2^n-1) = a(3*2^n-1)$.\n-/\n@[category research solved, AMS 11,\n  formal_proof using lean4 at\n    \"https://github.com/KitaKen1/oeis-a112970-formal-conjectures/blob/71ae72f443bd9bee7d958f0a19d9f9ec5ab82af5/lean/OeisA112970FC.lean#L56-L64\"]\ntheorem conjecture2 (n : ℕ) : a (2^n - 1) = a (3 * 2^n - 1) := by\n  sorry\n\nset_option linter.style.formal_proof_palomar false in\n/-- Conjecture: $a(2^n-1)=a(3*2^n-1)=1$. This formalizes the value part $a(2^n-1)=1$. -/\n@[category research solved, AMS 11,\n  formal_proof using lean4 at\n    \"https://github.com/KitaKen1/oeis-a112970-formal-conjectures/blob/71ae72f443bd9bee7d958f0a19d9f9ec5ab82af5/lean/OeisA112970FC.lean#L48-L54\"]\ntheorem conjecture3 (n : ℕ) : a (2^n - 1) = 1 := by\n  sorry\n\nend OeisA112970\n",
  "statement_hash": "29a61b6f827e033e7db285f008b315aeaba0c9c16e0a6a8e367d69b70dcc634a",
  "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."
}