{
  "id": "5128",
  "ident": "NS.05128",
  "slug": "oeis-185895",
  "title": "Coefficients of $\\prod_{k>0} (1 - x^k/k!)$",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "$a(n)$ differs in sign from $a(n-1)$ if and only if $n$ is a triangular number\n(checked up to $n = 1225 = (50 \\cdot 51)/2$).\n- _Peter Bala_, Mar 17 2022",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [
    "formal_proof"
  ],
  "collection": "oeis",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "OeisA185895.conjecture_1",
  "statement_lean": "theorem conjecture_1 (n : ℕ) (hn : 0 < n) :\n    a n * a (n - 1) < 0 ↔ n.IsTriangular",
  "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/-!\n# Coefficients of $\\prod_{k>0} (1 - x^k/k!)$\n\nThe sequence $a(n)$ has exponential generating function\n$$E(x) = \\prod_{k=1}^\\infty \\left(1 - \\frac{x^k}{k!}\\right),$$\nso that $a(n) = n! [x^n] \\prod_{k=1}^n \\left(1 - \\frac{x^k}{k!}\\right)$.\n\nSince $a(n)$ is a sum of multinomial coefficients with $\\pm$ signs, it is always\nan integer.\n\n*References:*\n- [A185895](https://oeis.org/A185895)\n-/\n\n@[expose] public section\n\nopen Polynomial\n\nnamespace OeisA185895\n\n/-- The finite polynomial approximation $\\prod_{k=1}^n (1 - X^k / k!)$. -/\nnoncomputable def p (n : ℕ) : Polynomial ℚ :=\n  ∏ k ∈ Finset.Icc 1 n, (1 - C (1 / (k.factorial : ℚ)) * X ^ k)\n\n@[category API, AMS 11]\nprivate lemma C_mul_X_pow_mul (a b : ℚ) (n m : ℕ) :\n    (C a * X ^ n) * (C b * X ^ m) = C (a * b) * X ^ (n + m) := by\n  rw [C_mul, pow_add]\n  ring\n\n/-- The sequence $a(n) = n! [x^n] \\prod_{k=1}^n (1 - x^k / k!)$. -/\nnoncomputable def a (n : ℕ) : ℤ :=\n  if n = 0 then 1\n  else (coeff (p n) n * (n.factorial : ℚ)).floor\n\n@[category test, AMS 11]\ntheorem a_0 : a 0 = 1 := by rfl\n\n@[category test, AMS 11]\ntheorem a_1 : a 1 = -1 := by\n  dsimp [a, p]\n  simp [coeff_one]\n  rfl\n\n@[category test, AMS 11]\ntheorem a_2 : a 2 = -1 := by\n  dsimp [a, p]\n  have hI : (Finset.Icc 1 2 : Finset ℕ) = {1, 2} := by decide\n  rw [hI, Finset.prod_insert (by decide), Finset.prod_singleton]\n  simp only [mul_sub, sub_mul, one_mul, mul_one, C_mul_X_pow_mul,\n    coeff_sub, coeff_one, coeff_C_mul_X_pow]\n  decide +kernel\n\n@[category test, AMS 11]\ntheorem a_3 : a 3 = 2 := by\n  dsimp [a, p]\n  have hI : (Finset.Icc 1 3 : Finset ℕ) = {1, 2, 3} := by decide\n  rw [hI, Finset.prod_insert (by decide), Finset.prod_insert (by decide), Finset.prod_singleton]\n  simp only [mul_sub, sub_mul, one_mul, mul_one, C_mul_X_pow_mul,\n    coeff_sub, coeff_one, coeff_C_mul_X_pow]\n  decide +kernel\n\n@[category test, AMS 11]\ntheorem a_4 : a 4 = 3 := by\n  dsimp [a, p]\n  have hI : (Finset.Icc 1 4 : Finset ℕ) = {1, 2, 3, 4} := by decide\n  rw [hI, Finset.prod_insert (by decide), Finset.prod_insert (by decide),\n      Finset.prod_insert (by decide), Finset.prod_singleton]\n  simp only [mul_sub, sub_mul, one_mul, mul_one, C_mul_X_pow_mul,\n    coeff_sub, coeff_one, coeff_C_mul_X_pow]\n  decide +kernel\n\n/-- The $n$-th coefficient of the square of the ordinary generating function $A(x)^2$. -/\nnoncomputable def c (n : ℕ) : ℤ :=\n  ∑ k ∈ Finset.range (n + 1), a k * a (n - k)\n\nset_option linter.style.formal_proof_palomar false in\n/--\n$a(n)$ differs in sign from $a(n-1)$ if and only if $n$ is a triangular number\n(checked up to $n = 1225 = (50 \\cdot 51)/2$).\n- _Peter Bala_, Mar 17 2022\n-/\n@[category research solved, AMS 11,\n  formal_proof using lean4 at \"https://github.com/epoch-research/LeanOpenProblems-results/blob/f02efd9a8c5fc6a735d2a90c33e24f7278ce0ffc/runs/oeis-lite-200usd-sol-nk5wh4g0vh3546nm/oeis_185895_conjecture_1/Submission/Spec.lean#L4835\"]\ntheorem conjecture_1 (n : ℕ) (hn : 0 < n) :\n    a n * a (n - 1) < 0 ↔ n.IsTriangular := by\n  sorry\n\nset_option linter.style.formal_proof_palomar false in\n/--\nThe coefficients $c(n)$ of $A(x)^2 = (\\sum_{n \\ge 0} a(n) x^n)^2$ differ in sign from $c(n-1)$\nif and only if $n$ is a triangular number.\n- _Peter Bala_, Mar 17 2022\n\n**Proof sketch** (the kernel-checked development lives at the `formal_proof` permalink below).\nWrite $a(n)/n! = \\sum_j (-1)^j L_j(n)$, where $L_j(n)$ is the sum of $\\prod_{s \\in S} 1/s!$ over\nall sets $S$ of $j$ distinct positive integers with sum $n$. A \"down map\" (lowering by one the\nleast element of $S$ above its first gap) gives $L_{k-1}(n) \\le \\frac{91}{100} L_k(n)$ for all\n$k \\ge 1$ and $n \\ge k(k+1)/2$. Hence the top nonzero layer $L_m(n)$ dominates, where\n$m(m+1)/2 \\le n < (m+1)(m+2)/2$; this reproves `conjecture_1` and gives\n$|a(n)| \\ge \\frac{9}{100} n! L_m(n)$. Since $c(n) = 2a(n) + \\sum_{0<k<n} a(k)a(n-k)$, the sign of\n$c(n)$ equals that of $a(n)$ whenever $\\sum_{0<k<n} |a(k)a(n-k)| < 2|a(n)|$. For $n \\le 2500$,\nconjecture 2 is checked in the kernel from a certified table of $a(n)$; for $n > 2500$, explicit\nestimates (rational arithmetic and elementary bounds only) bound the cross sum by\n$0.18 \\cdot n! L_m(n)$, which is less than $2|a(n)|$.\n-/\n@[category research solved, AMS 11,\n  formal_proof using lean4 at\n    \"https://github.com/kei825/oeis-a185895-conjecture2/blob/8ddd5a7d2bde415940f944440921fd760283f79d/OeisA185895Conjecture2.lean#L4959-L4961\"]\ntheorem conjecture_2 (n : ℕ) (hn : 0 < n) :\n    c n * c (n - 1) < 0 ↔ n.IsTriangular := by\n  sorry\n\nset_option linter.style.formal_proof_palomar false in\n/--\nThe Gauss congruences $a(n \\cdot p^k) \\equiv a(n \\cdot p^{k-1}) \\pmod{p^k}$ hold\nfor all primes $p$ and positive integers $n$ and $k$.\n- _Peter Bala_, Mar 17 2022\n-/\n@[category research solved, AMS 11,\n  formal_proof using lean4 at\n    \"https://github.com/KitaKen1/oeis-a185895-conjecture3/blob/e40e3db2b47beeef22b00a481fc3a41b518168d9/lean/OeisA185895Conjecture3FC.lean#L579-L589\"]\ntheorem conjecture_3 (p : ℕ) (hp : p.Prime) (n k : ℕ) (hn : 0 < n) (hk : 0 < k) :\n    a (n * p ^ k) ≡ a (n * p ^ (k - 1)) [ZMOD (p : ℤ) ^ k] := by\n  sorry\n\nend OeisA185895\n",
  "statement_hash": "36911051111a7a17400c2d6b33051a1b71b0c5fde18d7dd4618eee61e6d93c7f",
  "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."
}