{
  "id": "6409",
  "ident": "NS.06409",
  "slug": "oeis-375439",
  "title": "A cubic generating function with ternary substitution",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "\"Conjecture: $a(n)$ is odd iff $n$ is in A038754, which consists of numbers of the form\n$3^k$ and $2*3^k$.\"\n- Paul D. Hanna, Aug 21 2024.\n\nLean proof by Wentao Li, with AI assistance; see [Li26].",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [
    "formal_proof"
  ],
  "collection": "oeis",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "OeisA375439.conjecture",
  "statement_lean": "theorem conjecture (n : ℕ) (hn : 1 ≤ n) :\n    Odd (a n) ↔ ∃ k : ℕ, n = 3 ^ k ∨ n = 2 * 3 ^ k",
  "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 cubic generating function with ternary substitution\n\nThe coefficients of the generating function\n$A(x)=x+x^2+(2A(x)^3+A(x^3))/3$, with constant term $a(0)=0$.\n\n*References:*\n- [A375439](https://oeis.org/A375439)\n- [A038754](https://oeis.org/A038754)\n- [Li26] Wentao Li, [Parity of A375439](https://github.com/VictorLiwentao/lean-oeis-proofs/blob/0a23974e54b90afd1453ef02c27cf8f617bad940/proofs/new-proofs/A375439/PROOF.md), 2026.\n-/\n\n@[expose] public section\n\nnamespace OeisA375439\n\n/-- Coefficients of the square of a power series with coefficient sequence $b$. -/\ndef conv2 (b : ℕ → ℕ) (n : ℕ) : ℕ :=\n  ∑ k ∈ Finset.range (n + 1), b k * b (n - k)\n\n/-- Coefficients of the cube of a power series with coefficient sequence $b$. -/\ndef conv3 (b : ℕ → ℕ) (n : ℕ) : ℕ :=\n  ∑ k ∈ Finset.range (n + 1), conv2 b k * b (n - k)\n\n/-- Coefficients obtained by substituting $x^3$ for $x$. -/\ndef subst3 (b : ℕ → ℕ) (n : ℕ) : ℕ :=\n  if 3 ∣ n then b (n / 3) else 0\n\n/-- Coefficients of $2B(x)^3+B(x^3)$. -/\ndef rhs (b : ℕ → ℕ) (n : ℕ) : ℕ :=\n  2 * conv3 b n + subst3 b n\n\n/-- Coefficients of $A(x)=x+x^2+(2A(x)^3+A(x^3))/3$, with $a(0)=0$. -/\ndef a : ℕ → ℕ :=\n  Nat.strongRec fun n ih =>\n    if n = 0 then 0\n    else if n = 1 then 1\n    else if n = 2 then 1\n    else\n      let b : ℕ → ℕ := fun m => if h : m < n then ih m h else 0\n      rhs b n / 3\n\n/-- The coefficient recurrence unfolded at an index. -/\n@[category API, AMS 11]\ntheorem a_eq (n : ℕ) :\n    a n = if n = 0 then 0 else if n = 1 then 1 else if n = 2 then 1\n      else rhs (fun m => if m < n then a m else 0) n / 3 := by\n  rw [a, Nat.strongRec_eq]\n  simp only [a, dite_eq_ite]\n\n@[category test, AMS 11]\ntheorem a_0 : a 0 = 0 := by\n  rw [a_eq]\n  norm_num\n\n@[category test, AMS 11]\ntheorem a_1 : a 1 = 1 := by\n  rw [a_eq]\n  norm_num\n\n@[category test, AMS 11]\ntheorem a_2 : a 2 = 1 := by\n  rw [a_eq]\n  norm_num\n\n@[category test, AMS 11]\ntheorem a_3 : a 3 = 1 := by\n  rw [a_eq]\n  norm_num [rhs, conv3, conv2, subst3, Finset.sum_range_succ, a_0, a_1, a_2]\n\n@[category test, AMS 11]\ntheorem a_4 : a 4 = 2 := by\n  rw [a_eq]\n  norm_num [rhs, conv3, conv2, subst3, Finset.sum_range_succ, a_0, a_1, a_2, a_3]\n\n@[category test, AMS 11]\ntheorem a_5 : a 5 = 4 := by\n  rw [a_eq]\n  norm_num [rhs, conv3, conv2, subst3, Finset.sum_range_succ, a_0, a_1, a_2, a_3, a_4]\n\n@[category test, AMS 11]\ntheorem a_6 : a 6 = 9 := by\n  rw [a_eq]\n  norm_num [rhs, conv3, conv2, subst3, Finset.sum_range_succ, a_0, a_1, a_2, a_3, a_4, a_5]\n\nset_option linter.style.formal_proof_palomar false in\n/--\n\"Conjecture: $a(n)$ is odd iff $n$ is in A038754, which consists of numbers of the form\n$3^k$ and $2*3^k$.\"\n- Paul D. Hanna, Aug 21 2024.\n\nLean proof by Wentao Li, with AI assistance; see [Li26].\n-/\n@[category research solved, AMS 11,\n  formal_proof using lean4 at \"https://github.com/VictorLiwentao/lean-oeis-proofs/blob/0a23974e54b90afd1453ef02c27cf8f617bad940/LeanOeisProofs/NewProofs/A375439.lean#L382\"]\ntheorem conjecture (n : ℕ) (hn : 1 ≤ n) :\n    Odd (a n) ↔ ∃ k : ℕ, n = 3 ^ k ∨ n = 2 * 3 ^ k := by\n  sorry\n\nend OeisA375439\n",
  "statement_hash": "baf3c138828067b3fa03f3f59a7bffdfd412799211b914a0f08b824cbdeca602",
  "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."
}