/-
Copyright 2026 The Formal Conjectures Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-/
module
public import FormalConjecturesUtilA cubic generating function with ternary substitution
The coefficients of the generating function $A(x)=x+x^2+(2A(x)^3+A(x^3))/3$, with constant term $a(0)=0$.
References:
[Li26] Wentao Li, Parity of A375439, 2026.
@[expose] public sectionnamespace OeisA375439Coefficients of the square of a power series with coefficient sequence $b$.
def conv2 (b : ℕ → ℕ) (n : ℕ) : ℕ :=
∑ k ∈ Finset.range (n + 1), b k * b (n - k)Coefficients of the cube of a power series with coefficient sequence $b$.
def conv3 (b : ℕ → ℕ) (n : ℕ) : ℕ :=
∑ k ∈ Finset.range (n + 1), conv2 b k * b (n - k)Coefficients obtained by substituting $x^3$ for $x$.
def subst3 (b : ℕ → ℕ) (n : ℕ) : ℕ :=
if 3 ∣ n then b (n / 3) else 0Coefficients of $2B(x)^3+B(x^3)$.
def rhs (b : ℕ → ℕ) (n : ℕ) : ℕ :=
2 * conv3 b n + subst3 b nCoefficients of $A(x)=x+x^2+(2A(x)^3+A(x^3))/3$, with $a(0)=0$.
def a : ℕ → ℕ :=
Nat.strongRec fun n ih =>
if n = 0 then 0
else if n = 1 then 1
else if n = 2 then 1
else
let b : ℕ → ℕ := fun m => if h : m < n then ih m h else 0
rhs b n / 3The coefficient recurrence unfolded at an index.
n:ℕ⊢ (if n = 0 then 0
else
if n = 1 then 1
else
if n = 2 then 1
else
have b := fun m ↦
if h : m < n then
(fun m x ↦
Nat.strongRec
(fun n ih ↦
if n = 0 then 0
else
if n = 1 then 1
else
if n = 2 then 1
else
have b := fun m ↦ if h : m < n then ih m h else 0;
rhs b n / 3)
m)
m h
else 0;
rhs b n / 3) =
if n = 0 then 0 else if n = 1 then 1 else if n = 2 then 1 else rhs (fun m ↦ if m < n then a m else 0) n / 3
simp only [a, dite_eq_ite] All goals completed! 🐙
@[category test, AMS 11]
theorem a_0 : a 0 = 0 := by ⊢ a 0 = 0
rw [a_eq ⊢ (if 0 = 0 then 0 else if 0 = 1 then 1 else if 0 = 2 then 1 else rhs (fun m ↦ if m < 0 then a m else 0) 0 / 3) = 0 ⊢ (if 0 = 0 then 0 else if 0 = 1 then 1 else if 0 = 2 then 1 else rhs (fun m ↦ if m < 0 then a m else 0) 0 / 3) = 0] ⊢ (if 0 = 0 then 0 else if 0 = 1 then 1 else if 0 = 2 then 1 else rhs (fun m ↦ if m < 0 then a m else 0) 0 / 3) = 0
norm_num All goals completed! 🐙
@[category test, AMS 11]
theorem a_1 : a 1 = 1 := by ⊢ a 1 = 1
rw [a_eq ⊢ (if 1 = 0 then 0 else if 1 = 1 then 1 else if 1 = 2 then 1 else rhs (fun m ↦ if m < 1 then a m else 0) 1 / 3) = 1 ⊢ (if 1 = 0 then 0 else if 1 = 1 then 1 else if 1 = 2 then 1 else rhs (fun m ↦ if m < 1 then a m else 0) 1 / 3) = 1] ⊢ (if 1 = 0 then 0 else if 1 = 1 then 1 else if 1 = 2 then 1 else rhs (fun m ↦ if m < 1 then a m else 0) 1 / 3) = 1
norm_num All goals completed! 🐙
@[category test, AMS 11]
theorem a_2 : a 2 = 1 := by ⊢ a 2 = 1
rw [a_eq ⊢ (if 2 = 0 then 0 else if 2 = 1 then 1 else if 2 = 2 then 1 else rhs (fun m ↦ if m < 2 then a m else 0) 2 / 3) = 1 ⊢ (if 2 = 0 then 0 else if 2 = 1 then 1 else if 2 = 2 then 1 else rhs (fun m ↦ if m < 2 then a m else 0) 2 / 3) = 1] ⊢ (if 2 = 0 then 0 else if 2 = 1 then 1 else if 2 = 2 then 1 else rhs (fun m ↦ if m < 2 then a m else 0) 2 / 3) = 1
norm_num All goals completed! 🐙
@[category test, AMS 11]
theorem a_3 : a 3 = 1 := by ⊢ a 3 = 1
rw [a_eq ⊢ (if 3 = 0 then 0 else if 3 = 1 then 1 else if 3 = 2 then 1 else rhs (fun m ↦ if m < 3 then a m else 0) 3 / 3) = 1 ⊢ (if 3 = 0 then 0 else if 3 = 1 then 1 else if 3 = 2 then 1 else rhs (fun m ↦ if m < 3 then a m else 0) 3 / 3) = 1] ⊢ (if 3 = 0 then 0 else if 3 = 1 then 1 else if 3 = 2 then 1 else rhs (fun m ↦ if m < 3 then a m else 0) 3 / 3) = 1
norm_num [rhs, conv3, conv2, subst3, Finset.sum_range_succ, a_0, a_1, a_2] All goals completed! 🐙
@[category test, AMS 11]
theorem a_4 : a 4 = 2 := by ⊢ a 4 = 2
rw [a_eq ⊢ (if 4 = 0 then 0 else if 4 = 1 then 1 else if 4 = 2 then 1 else rhs (fun m ↦ if m < 4 then a m else 0) 4 / 3) = 2 ⊢ (if 4 = 0 then 0 else if 4 = 1 then 1 else if 4 = 2 then 1 else rhs (fun m ↦ if m < 4 then a m else 0) 4 / 3) = 2] ⊢ (if 4 = 0 then 0 else if 4 = 1 then 1 else if 4 = 2 then 1 else rhs (fun m ↦ if m < 4 then a m else 0) 4 / 3) = 2
norm_num [rhs, conv3, conv2, subst3, Finset.sum_range_succ, a_0, a_1, a_2, a_3] All goals completed! 🐙
@[category test, AMS 11]
theorem a_5 : a 5 = 4 := by ⊢ a 5 = 4
rw [a_eq ⊢ (if 5 = 0 then 0 else if 5 = 1 then 1 else if 5 = 2 then 1 else rhs (fun m ↦ if m < 5 then a m else 0) 5 / 3) = 4 ⊢ (if 5 = 0 then 0 else if 5 = 1 then 1 else if 5 = 2 then 1 else rhs (fun m ↦ if m < 5 then a m else 0) 5 / 3) = 4] ⊢ (if 5 = 0 then 0 else if 5 = 1 then 1 else if 5 = 2 then 1 else rhs (fun m ↦ if m < 5 then a m else 0) 5 / 3) = 4
norm_num [rhs, conv3, conv2, subst3, Finset.sum_range_succ, a_0, a_1, a_2, a_3, a_4] All goals completed! 🐙
@[category test, AMS 11]
theorem a_6 : a 6 = 9 := by ⊢ a 6 = 9
rw [a_eq ⊢ (if 6 = 0 then 0 else if 6 = 1 then 1 else if 6 = 2 then 1 else rhs (fun m ↦ if m < 6 then a m else 0) 6 / 3) = 9 ⊢ (if 6 = 0 then 0 else if 6 = 1 then 1 else if 6 = 2 then 1 else rhs (fun m ↦ if m < 6 then a m else 0) 6 / 3) = 9] ⊢ (if 6 = 0 then 0 else if 6 = 1 then 1 else if 6 = 2 then 1 else rhs (fun m ↦ if m < 6 then a m else 0) 6 / 3) = 9
norm_num [rhs, conv3, conv2, subst3, Finset.sum_range_succ, a_0, a_1, a_2, a_3, a_4, a_5] All goals completed! 🐙"Conjecture: $a(n)$ is odd iff $n$ is in A038754, which consists of numbers of the form $3^k$ and $2*3^k$."
Paul D. Hanna, Aug 21 2024.
Lean proof by Wentao Li, with AI assistance; see [Li26].
@[category research solved, AMS 11,
formal_proof using lean4 at "https://github.com/VictorLiwentao/lean-oeis-proofs/blob/0a23974e54b90afd1453ef02c27cf8f617bad940/LeanOeisProofs/NewProofs/A375439.lean#L382"]
theorem conjecture (n : ℕ) (hn : 1 ≤ n) :
Odd (a n) ↔ ∃ k : ℕ, n = 3 ^ k ∨ n = 2 * 3 ^ k := by n:ℕhn:1 ≤ n⊢ Odd (a n) ↔ ∃ k, n = 3 ^ k ∨ n = 2 * 3 ^ k
sorry All goals completed! 🐙end OeisA375439