mathlib4 review helperopen PRs by @wwylele on leanprover-community/mathlib4

← queue

#43220 refactor(Combinatorics/Partition): eliminate T2Space requirement from generating function

t-combinatorics maintainer-merge CI success ✓ felixpernegger

+100 −80 · 3 files · 8 commits · head 85fccd0 · updated 3 days ago · Files changed on GitHub

In plain words

Refactors the product formula for the partition generating function Nat.Partition.genFun (for a character over a commutative semiring , ) so that it no longer needs to be Hausdorff. The inner infinite sums are replaced by an explicit power series genFunFactor f i, defined coefficientwise; hasProd_genFun now states for any topology on , and the old tsum form survives as hasProd_genFun' under [T2Space R]. The Glaisher file switches to the primed lemma.

The transcriptions were written for revision 8057546; the PR is now at 85fccd0. Check them against the code.

Transcriptions are drafted with an LLM from the diff and are a reading aid, not a verified statement: the Lean code is the reference.

PR description

Previously, the key lemma in this file had the shape HasProd (fun i ↦ 1 + ∑' j, f (i + 1) (j + 1) • X ^ ((i + 1) * (j + 1))) (genFun f), which has a nested infinite sum inside the infinite prod. As a result, all related lemma needed T2Space when it doesn't have to. The new formulation extract the inner sum into a power series definition genFunTerm that works in general topological space, eliminating T2Space for the HasProd/HasSum lemma.

The old formula is kept under the name hasProd_genFun'. This is still used in the downstream file Glaisher.lean. To reduce the code change size, the refactor in Glaisher.lean is deferred to a future PR


Context: this was brought up in #33157

![Open in Gitpod](gitpod.io/from-referrer/)

Conversation on GitHub 18
github-actions[bot] · comment · 2026-08-30
PR summary 85fccd0c06
Import changes for modified files

No significant changes to the import graph

<details><summary>Import changes for all files</summary>

|Files|Import difference| |-|-|

</details>


<details><summary>

Declarations diff (regex)

</summary>

+ coeff_genFunTerm + coeff_genFunTerm_eq_zero_of_not_dvd + coeff_genFunTerm_self + constantCoeff_genFunTerm + dvd_of_coeff_genFunTerm_ne_zero + genFunTerm + genFunTerm_eq_tsum + hasProd_genFun' + hasSum_genFunTerm + multipliable_one_add_genFunTerm <details> <summary>You can run this locally as follows</summary>

## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

</details>

The doc-module for scripts/pr_summary/declarations_diff.sh in the undefined repository contains some details about this script.

</details>

<details><summary>

Declarations diff (Lean)

</summary>

✅ Lean-aware diff — post-build, computed from the Lean environment (commit 85fccd0).

  • +12 new declarations
  • −0 removed declarations
+Nat.Partition.coeff_genFunTerm
+Nat.Partition.coeff_genFunTerm_eq_zero_of_not_dvd
+Nat.Partition.coeff_genFunTerm_self
+Nat.Partition.constantCoeff_genFunTerm
+Nat.Partition.dvd_of_coeff_genFunTerm_ne_zero
+Nat.Partition.genFunTerm
+Nat.Partition.genFunTerm_eq_tsum
+Nat.Partition.hasProd_genFun'
+Nat.Partition.hasSum_genFunTerm
+Nat.Partition.multipliable_one_add_genFunTerm
+Nat.Partition.toFinsuppAntidiag_apply
+Nat.Partition.toFinsuppAntidiag_support

</details>


No changes to strong technical debt. No changes to weak technical debt.

Current commit 85fccd0c06 Reference commit 065b579eb3

This script lives in the undefined repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.py pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).
copilot-pull-request-reviewer[bot] · commented · 2026-08-30

Pull request overview

Refactors partition generating functions to avoid unnecessary T2Space assumptions.

Changes:

  • Introduces coefficient-defined genFunFactor.
  • Generalizes HasSum, HasProd, and multipliability results.
  • Preserves the nested-sum formulation for Glaisher compatibility.
Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

| File | Description | | ---- | ----------- | | GenFun.lean | Adds and proves the factor-based generating-function API. | | Glaisher.lean | Uses the compatibility product theorem. |


💡 <a href="/leanprover-community/mathlib4/new/master?filename=.github/skills/code-review/SKILL.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a code-review agent skill</a> or configure MCP servers for context-aware, tailored reviews. <a href="docs.github.com/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review?tool=webui#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>

Copilot · on Mathlib/Combinatorics/Enumerative/Partition/GenFun.lean:24 (outdated) · 2026-08-30

The displayed second equation contains the nested tsum, but hasProd_genFun now concludes with 1 + genFunFactor; the theorem matching the displayed formula is hasProd_genFun'. Please distinguish the factor-based theorem from the compatibility theorem so these API references remain accurate.

mathlib-merge-conflicts[bot] · comment · 2026-10-09

This pull request has conflicts, please merge master and resolve them.

wwylele · on Mathlib/Combinatorics/Enumerative/Partition/GenFun.lean:163 (outdated) · 2026-11-28
  contrapose h
felixpernegger · on Mathlib/Combinatorics/Enumerative/Partition/GenFun.lean:82 (outdated) · 2026-12-03

is there any reason for this being noncomputable? also the othe noncomputable def in this file

felixpernegger · on Mathlib/Combinatorics/Enumerative/Partition/GenFun.lean:80 (outdated) · 2026-12-03

this technically isnt the factor

felixpernegger · on Mathlib/Combinatorics/Enumerative/Partition/GenFun.lean:23 (outdated) · 2026-12-03
expression, the factors in the second equation are defined as `Nat.Partition.genFunFactor`, and its
felixpernegger · on Mathlib/Combinatorics/Enumerative/Partition/GenFun.lean:100 (outdated) · 2026-12-03

add contraposition of this also?

felixpernegger · on Mathlib/Combinatorics/Enumerative/Partition/GenFun.lean:113 (outdated) · 2026-12-03
  rw [Finsupp.prod, Multiset.toFinsupp_support]
  refine prod_subset_one_on_sdiff (by grind) (by simp_all) fun i hi ↦ ?_
  simp_all [(p.parts_pos (Multiset.mem_toFinset.mp hi)).ne']
felixpernegger · on Mathlib/Combinatorics/Enumerative/Partition/GenFun.lean:167 (outdated) · 2026-12-03
  rintro ⟨_, k, rfl⟩
  exact h ⟨k - 1, by grind⟩
felixpernegger · on Mathlib/Combinatorics/Enumerative/Partition/GenFun.lean:82 (outdated) · 2026-12-03

can you add a lemma connecting this with the tsum its replacing maybe? (i dont think there is one)

wwylele · on Mathlib/Combinatorics/Enumerative/Partition/GenFun.lean:82 (outdated) · 2026-12-03

Something probably has changed across versions and made these computable. Let me fix them

wwylele · on Mathlib/Combinatorics/Enumerative/Partition/GenFun.lean:82 (outdated) · 2026-12-03

added genFunTerm_eq_tsum

wwylele · on Mathlib/Combinatorics/Enumerative/Partition/GenFun.lean:80 (outdated) · 2026-12-03

Renamed to genFunTerm

wwylele · comment · 2026-12-03

Thanks for the review!

-awaiting-author

felixpernegger · approved · 2026-12-03

maintainer merge

github-actions[bot] · comment · 2026-12-03

🚀 Pull request has been placed on the maintainer queue by felixpernegger.

Mathlib/Combinatorics/Enumerative/Partition/Basic.lean +1 −0

def ofSymShapeEquiv (μ : Partition n) (e : σ ≃ τ) :
def toFinsuppAntidiag changedL126–132
126/-- Convert a `Partition n` to a member of `(Finset.Icc 1 n).finsuppAntidiag n`
127(see `Nat.Partition.toFinsuppAntidiag_mem_finsuppAntidiag` for the proof).
128`p.toFinsuppAntidiag i` is defined as `i` times the number of occurrence of `i` in `p`. -/
129@[simps]
130def toFinsuppAntidiag {n : ℕ} (p : Partition n) : ℕ →₀ ℕ where
131 toFun m := p.parts.count m * m
132 support := p.parts.toFinset

Mathlib/Combinatorics/Enumerative/Partition/GenFun.lean +97 −78

G_f(X) = \sum_{n = 0}^{\infty} \left(\sum_{p \in P_{n}} \prod_{i \in p} f(i, \#i
19$$
20where $P_n$ is all partitions of $n$, $\#i$ is the count of $i$ in the partition $p$.
21We give the definition `Nat.Partition.genFun` using the first equation, and prove the second
−equation in `Nat.Partition.hasProd_genFun` (with shifted indices).
22equation in `Nat.Partition.hasProd_genFun` (with shifted indices). To avoid nested infinite
23expression, the terms in the second equation are defined as `Nat.Partition.genFunTerm`, and its
24equivalence to the infinite sum is shown at `Nat.Partition.hasSum_genFunTerm`.
26This generating function can be specialized to
27* When $f(i, c) = 1$, this is the generating function for partition function $p(n)$
multiplied within one `n.Partition`, and summed among all `n.Partition` for a fi
55each `n` is assigned a value, which we use as the coefficients of the power series.
57See the module docstring of `Combinatorics.Enumerative.Partition.GenFun` for more details. -/
def genFun changedL58–59
−noncomputable def genFun (f : ℕ → ℕ → R) : R⟦X⟧ :=
58def genFun (f : ℕ → ℕ → R) : R⟦X⟧ :=
59 PowerSeries.mk fun n ↦ ∑ p : n.Partition, p.parts.toFinsupp.prod f
lemma coeff_genFun changedL61–65
61@[simp]
62lemma coeff_genFun (f : ℕ → ℕ → R) (n : ℕ) :
63 (genFun f).coeff n = ∑ p : n.Partition, p.parts.toFinsupp.prod f :=
64 PowerSeries.coeff_mk _ _
−/-- The summands in the formula `Nat.Partition.hasProd_genFun` tends to infinity in their order. -/
66-- TODO: this was an intermediate lemma in this file but is no longer in use. Generalize this
67-- and move this to a better place.
68theorem tendsto_order_genFun_term_atTop_nhds_top (f : ℕ → ℕ → R) (i : ℕ) :
69 Filter.Tendsto (fun j ↦ (f (i + 1) (j + 1) • (X : R⟦X⟧) ^ ((i + 1) * (j + 1))).order)
70 Filter.atTop (nhds ⊤) := by
theorem tendsto_order_genFun_term_atTop_nhds_top (f : ℕ → ℕ → R) (i :
77 norm_cast
78 grind
−variable [TopologicalSpace R]
def genFunTerm newL80–83
80/-- Term for part $i$ of the generating function associated with character $f(i, c)$ for partition
81functions. -/
82def genFunTerm (f : ℕ → ℕ → R) (i : ℕ) : R⟦X⟧ :=
83 PowerSeries.mk fun n ↦ if n ≠ 0 ∧ i ∣ n then f i (n / i) else 0
theorem summable_genFun_term removedLundefined–undefined
−/-- The infinite sum in the formula `Nat.Partition.hasProd_genFun` always converges. -/
−theorem summable_genFun_term (f : ℕ → ℕ → R) (i : ℕ) :
− Summable fun j ↦ f (i + 1) (j + 1) • (X : R⟦X⟧) ^ ((i + 1) * (j + 1)) := by
− apply WithPiTopology.summable_of_tendsto_order_atTop_nhds_top
− apply tendsto_order_genFun_term_atTop_nhds_top
theorem constantCoeff_genFunTerm newL85–88
85@[simp]
86theorem constantCoeff_genFunTerm (f : ℕ → ℕ → R) (i : ℕ) :
87 (genFunTerm f i).constantCoeff = 0 := by
88 simp [genFunTerm]
theorem summable_genFun_term' removedLundefined–undefined
−/-- Alternative form of `summable_genFun_term` that unshifts the first index. -/
−theorem summable_genFun_term' (f : ℕ → ℕ → R) {i : ℕ} (hi : i ≠ 0) :
− Summable fun j ↦ f i (j + 1) • (X : R⟦X⟧) ^ (i * (j + 1)) := by
− obtain ⟨a, rfl⟩ := Nat.exists_eq_add_one_of_ne_zero hi
− apply summable_genFun_term
theorem coeff_genFunTerm newL90–93
90@[simp]
91theorem coeff_genFunTerm (f : ℕ → ℕ → R) {i j : ℕ} (hi : i ≠ 0) (hj : j ≠ 0) :
92 (genFunTerm f i).coeff (j * i) = f i j := by
93 simp [genFunTerm, hi, hj]
−variable [T2Space R]
theorem coeff_genFunTerm_self newL95–98
95@[simp]
96theorem coeff_genFunTerm_self (f : ℕ → ℕ → R) {i : ℕ} (hi : i ≠ 0) :
97 (genFunTerm f i).coeff i = f i 1 := by
98 simpa using coeff_genFunTerm f hi (one_ne_zero)
theorem dvd_of_coeff_genFunTerm_ne_zero newL100–102
100theorem dvd_of_coeff_genFunTerm_ne_zero {f : ℕ → ℕ → R} {i n : ℕ}
101 (h : (genFunTerm f i).coeff n ≠ 0) : i ∣ n := by
102 simp_all [genFunTerm]
theorem coeff_genFunTerm_eq_zero_of_not_dvd newL104–106
104theorem coeff_genFunTerm_eq_zero_of_not_dvd {f : ℕ → ℕ → R} {i n : ℕ} (h : ¬ i ∣ n) :
105 (genFunTerm f i).coeff n = 0 :=
106 Not.imp_symm dvd_of_coeff_genFunTerm_ne_zero h
theorem aux_dvd_of_coeff_ne_zero removedLundefined–undefined
−private theorem aux_dvd_of_coeff_ne_zero {f : ℕ → ℕ → R} {d : ℕ} {s : Finset ℕ} (hs0 : 0 ∉ s)
− {g : ℕ →₀ ℕ} (hg : g ∈ s.finsuppAntidiag d)
− (hprod : ∀ i ∈ s, (coeff (g i)) (1 + ∑' j, f i (j + 1) • X ^ (i * (j + 1))) ≠ (0 : R)) (x : ℕ) :
theorem aux_prod_f_eq_prod_coeff newL108–113
108private theorem aux_prod_f_eq_prod_coeff (f : ℕ → ℕ → R) {n : ℕ} (p : Partition n) {s : Finset ℕ}
109 (hs : Icc 1 n ⊆ s) :
110 p.parts.toFinsupp.prod f = ∏ i ∈ s, coeff (p.toFinsuppAntidiag i) (1 + genFunTerm f i) := by
111 rw [Finsupp.prod, Multiset.toFinsupp_support]
112 refine prod_subset_one_on_sdiff (by grind) (by simp_all) fun i hi ↦ ?_
113 simp_all [(p.parts_pos (Multiset.mem_toFinset.mp hi)).ne']
theorem aux_dvd_of_coeff_ne_zero changedL115–127
115private theorem aux_dvd_of_coeff_ne_zero {f : ℕ → ℕ → R} {d : ℕ} {s : Finset ℕ}
116 {g : ℕ →₀ ℕ} (hg : g ∈ s.finsuppAntidiag d) (hcoeff : ∀ i ∈ s, (coeff (g i))
117 (1 + genFunTerm f i) ≠ 0) (x : ℕ) :
118 x ∣ g x := by
119 by_cases hx : x ∈ s
− · specialize hprod x hx
− contrapose hprod
− have hx0 : x ≠ 0 := fun h ↦ hs0 (h ▸ hx)
− rw [map_add, (summable_genFun_term' f hx0).map_tsum _ (WithPiTopology.continuous_coeff _ _)]
− rw [show (0 : R) = 0 + ∑' (i : ℕ), 0 by simp]
− congrm (?_ + ∑' (i : ℕ), ?_)
− · suffices g x ≠ 0 by simp [this]
− contrapose hprod
− simp [hprod]
− · rw [map_smul, coeff_X_pow]
− apply smul_eq_zero_of_right
− suffices g x ≠ x * (i + 1) by simp [this]
− contrapose hprod
− simp [hprod]
120 · by_cases hgx : g x = 0
121 · simp [hgx]
122 specialize hcoeff x hx
123 simp only [map_add, coeff_one, hgx, ↓reduceIte, zero_add] at hcoeff
124 exact dvd_of_coeff_genFunTerm_ne_zero hcoeff
125 · suffices g x = 0 by simp [this]
126 contrapose! hx
127 exact mem_of_subset (mem_finsuppAntidiag.mp hg).2 <| by simpa using hx
theorem aux_prod_coeff_eq_zero_of_notMem_range changedL129–151
129private theorem aux_prod_coeff_eq_zero_of_notMem_range (f : ℕ → ℕ → R) {d : ℕ} {s : Finset ℕ}
130 (hs0 : 0 ∉ s) {g : ℕ →₀ ℕ} (hg : g ∈ s.finsuppAntidiag d)
131 (hg' : g ∉ Set.range (toFinsuppAntidiag (n := d))) :
− ∏ i ∈ s, (coeff (g i)) (1 + ∑' j, f i (j + 1) • X ^ (i * (j + 1)) : R⟦X⟧) = 0 := by
− suffices ∃ i ∈ s, (coeff (g i)) ((1 : R⟦X⟧) + ∑' j, f i (j + 1) • X ^ (i * (j + 1))) = 0 by
132 ∏ i ∈ s, (1 + genFunTerm f i).coeff (g i) = 0 := by
133 suffices ∃ i ∈ s, (1 + genFunTerm f i).coeff (g i) = 0 by
134 obtain ⟨i, hi, hi'⟩ := this
− apply prod_eq_zero hi hi'
135 exact prod_eq_zero hi hi'
136 contrapose! hg' with hprod
− rw [Set.mem_range]
137 have hgne0 (i : ℕ) : g i ≠ 0 ↔ i ≠ 0 ∧ i ≤ g i := by
138 refine ⟨fun h ↦ ⟨?_, ?_⟩, by grind⟩
139 · contrapose hs0 with rfl
140 exact mem_of_subset (mem_finsuppAntidiag.mp hg).2 (by simpa using h)
− · exact Nat.le_of_dvd (Nat.pos_of_ne_zero h) <| aux_dvd_of_coeff_ne_zero hs0 hg hprod _
141 · exact Nat.le_of_dvd (Nat.pos_of_ne_zero h) <| aux_dvd_of_coeff_ne_zero hg hprod _
142 refine ⟨Nat.Partition.mk (Finsupp.mk g.support (fun i ↦ g i / i) ?_).toMultiset ?_ ?_, ?_⟩
143 · simpa using hgne0
− · suffices ∀ i, g i ≠ 0 → i ≠ 0 by simpa [Nat.pos_iff_ne_zero]
− exact fun i h ↦ ((hgne0 i).mp h).1
− · obtain ⟨h1, h2⟩ := mem_finsuppAntidiag.mp hg
− refine Eq.trans ?_ h1
144 · suffices ∀ i, g i ≠ 0 → 0 < i by simpa
145 exact fun i h ↦ Nat.pos_iff_ne_zero.mpr ((hgne0 i).mp h).1
146 · obtain ⟨rfl, h⟩ := mem_finsuppAntidiag.mp hg
147 suffices ∑ x ∈ g.support, g x / x * x = ∑ x ∈ s, g x by simpa [Finsupp.sum]
− apply sum_subset_zero_on_sdiff h2 (by simp)
− exact fun x hx ↦ Nat.div_mul_cancel <| aux_dvd_of_coeff_ne_zero hs0 hg hprod x
148 apply sum_subset_zero_on_sdiff h (by simp)
149 exact fun x hx ↦ Nat.div_mul_cancel <| aux_dvd_of_coeff_ne_zero hg hprod x
150 · ext x
− simpa [toFinsuppAntidiag] using Nat.div_mul_cancel <| aux_dvd_of_coeff_ne_zero hs0 hg hprod x
151 simpa using Nat.div_mul_cancel <| aux_dvd_of_coeff_ne_zero hg hprod x
theorem aux_prod_f_eq_prod_coeff removedLundefined–undefined
−private theorem aux_prod_f_eq_prod_coeff (f : ℕ → ℕ → R) {n : ℕ} (p : Partition n) {s : Finset ℕ}
− (hs : Icc 1 n ⊆ s) (hs0 : 0 ∉ s) :
− p.parts.toFinsupp.prod f =
− ∏ i ∈ s, coeff (p.toFinsuppAntidiag i) (1 + ∑' j, f i (j + 1) • X ^ (i * (j + 1))) := by
− simp_rw [Finsupp.prod, Multiset.toFinsupp_support, Multiset.toFinsupp_apply]
− apply prod_subset_one_on_sdiff
− · grind
− · intro x hx
− rw [mem_sdiff, Multiset.mem_toFinset] at hx
− have hx0 : x ≠ 0 := fun h ↦ hs0 (h ▸ hx.1)
− have hsum := (summable_genFun_term' f hx0).map_tsum _
− (WithPiTopology.continuous_constantCoeff R)
− simp [toFinsuppAntidiag, hsum, hx.2, hx0]
− · intro i hi
− rw [Multiset.mem_toFinset] at hi
− have hi0 : i ≠ 0 := (p.parts_pos hi).ne.symm
− rw [map_add, (summable_genFun_term' f hi0).map_tsum _ (WithPiTopology.continuous_coeff _ _)]
− suffices f i (Multiset.count i p.parts) =
− ∑' j, if Multiset.count i p.parts * i = i * (j + 1) then f i (j + 1) else 0 by
− simpa [toFinsuppAntidiag, hi, hi0, coeff_X_pow]
− rw [tsum_eq_single (Multiset.count i p.parts - 1) ?_]
− · rw [mul_comm]
− simp [Nat.sub_add_cancel (Multiset.one_le_count_iff_mem.mpr hi)]
− intro b hb
− suffices Multiset.count i p.parts * i ≠ i * (b + 1) by simp [this]
− rw [mul_comm i, (mul_left_inj' (Nat.ne_zero_of_lt (p.parts_pos hi))).ne]
− grind
153variable [TopologicalSpace R]
theorem hasSum_genFunTerm newL155–164
155theorem hasSum_genFunTerm (f : ℕ → ℕ → R) {i : ℕ} (hi : i ≠ 0) :
156 HasSum (fun j ↦ f i (j + 1) • (X : R⟦X⟧) ^ (i * (j + 1))) (genFunTerm f i) := by
157 have hinj : Function.Injective (fun j ↦ i * (j + 1)) :=
158 (mul_right_injective₀ hi).comp (add_left_injective 1)
159 convert! (hinj.hasSum_iff ?_).mpr (genFunTerm f i).hasSum_of_monomials_self with j
160 · simp [genFunTerm, hi, monomial_eq_C_mul_X_pow, smul_eq_C_mul]
161 intro n h
162 suffices ¬(n ≠ 0 ∧ i ∣ n) by simp [genFunTerm, this]
163 rintro ⟨_, k, rfl⟩
164 exact h ⟨k - 1, by grind⟩
theorem summable_genFun_term newL166–168
166theorem summable_genFun_term (f : ℕ → ℕ → R) (i : ℕ) :
167 Summable fun j ↦ f (i + 1) (j + 1) • (X : R⟦X⟧) ^ ((i + 1) * (j + 1)) :=
168 (hasSum_genFunTerm f (by simp)).summable
theorem summable_genFun_term' newL170–172
170theorem summable_genFun_term' (f : ℕ → ℕ → R) {i : ℕ} (hi : i ≠ 0) :
171 Summable fun j ↦ f i (j + 1) • (X : R⟦X⟧) ^ (i * (j + 1)) :=
172 (hasSum_genFunTerm f hi).summable
theorem hasProd_genFun changedL174–182
174theorem hasProd_genFun (f : ℕ → ℕ → R) :
− HasProd (fun i ↦ 1 + ∑' j, f (i + 1) (j + 1) • X ^ ((i + 1) * (j + 1))) (genFun f) := by
175 HasProd (fun i ↦ 1 + genFunTerm f (i + 1)) (genFun f) := by
176 rw [HasProd, WithPiTopology.tendsto_iff_coeff_tendsto]
177 refine fun d ↦ tendsto_atTop_of_eventually_const (fun s (hs : s ≥ range d) ↦ ?_)
− have : ∏ i ∈ s, ((1 : R⟦X⟧) + ∑' j, f (i + 1) (j + 1) • X ^ ((i + 1) * (j + 1)))
− = ∏ i ∈ s.map (addRightEmbedding 1), (1 + ∑' j, f i (j + 1) • X ^ (i * (j + 1))) := by simp
178 have : ∏ i ∈ s, (1 + genFunTerm f (i + 1)) =
179 ∏ i ∈ s.map (addRightEmbedding 1), (1 + genFunTerm f i) := by simp
180 rw [this]
181 have hs : Icc 1 d ⊆ s.map (addRightEmbedding 1) := by
182 intro i
theorem hasProd_genFun (f : ℕ → ℕ → R) :
188 · intro p _
189 exact mem_of_subset (finsuppAntidiag_mono hs _) p.toFinsuppAntidiag_mem_finsuppAntidiag
190 · exact fun g hg hg' ↦ aux_prod_coeff_eq_zero_of_notMem_range f (by simp) hg (by simpa using hg')
− · exact fun p _ ↦ aux_prod_f_eq_prod_coeff f p hs (by simp)
191 · exact fun p _ ↦ aux_prod_f_eq_prod_coeff f p hs
theorem multipliable_genFun removedLundefined–undefined
−theorem multipliable_genFun (f : ℕ → ℕ → R) :
− Multipliable fun i ↦ (1 : R⟦X⟧) + ∑' j, f (i + 1) (j + 1) • X ^ ((i + 1) * (j + 1)) :=
theorem multipliable_one_add_genFunTerm changedL193–195
193theorem multipliable_one_add_genFunTerm (f : ℕ → ℕ → R) :
194 Multipliable fun i ↦ 1 + genFunTerm f (i + 1) :=
195 (hasProd_genFun f).multipliable
197@[deprecated (since := "2026-08-30")] alias multipliable_genFun := multipliable_one_add_genFunTerm
199variable [T2Space R]
theorem genFunTerm_eq_tsum newL201–203
201theorem genFunTerm_eq_tsum (f : ℕ → ℕ → R) {i : ℕ} (hi : i ≠ 0) :
202 genFunTerm f i = ∑' j, f i (j + 1) • (X : R⟦X⟧) ^ (i * (j + 1)) :=
203 (hasSum_genFunTerm f hi).tsum_eq.symm
theorem hasProd_genFun' newL205–210
205/-- Expanded form of `Nat.Partition.hasProd_genFun`. This will be deprecated once downstream usage
206is refactored. -/
207theorem hasProd_genFun' (f : ℕ → ℕ → R) :
felixpernegger · 2026-12-03

maybe add doc that this is to be deprecated then?

208 HasProd (fun i ↦ 1 + ∑' j, f (i + 1) (j + 1) • X ^ ((i + 1) * (j + 1))) (genFun f) := by
209 convert ← hasProd_genFun f with i
210 exact genFunTerm_eq_tsum f (by simp)
theorem genFun_eq_tprod changedL212–214
212theorem genFun_eq_tprod (f : ℕ → ℕ → R) :
− genFun f = ∏' i, (1 + ∑' j, f (i + 1) (j + 1) • X ^ ((i + 1) * (j + 1))) :=
213 genFun f = ∏' i, (1 + genFunTerm f (i + 1)) :=
214 (hasProd_genFun f).tprod_eq.symm
216end Nat.Partition

Mathlib/Combinatorics/Enumerative/Partition/Glaisher.lean +2 −2

theorem hasProd_powerSeriesMk_card_restricted [IsTopologicalSemiring R]
theorem hasProd_powerSeriesMk_card_restricted body changedL53–59
53 (p : ℕ → Prop) [DecidablePred p] :
54 HasProd (fun i ↦ if p (i + 1) then ∑' j : ℕ, X ^ ((i + 1) * j) else 1)
55 (PowerSeries.mk fun n ↦ (#(restricted n p) : R)) := by
− convert hasProd_genFun (fun i c ↦ if p i then (1 : R) else 0) using 1
56 convert hasProd_genFun' (fun i c ↦ if p i then (1 : R) else 0) using 1
57 · ext1 i
58 split_ifs
59 · rw [tsum_eq_zero_add' ?_]
theorem hasProd_powerSeriesMk_card_countRestricted {m : ℕ} (hm : 0 < m) :
theorem hasProd_powerSeriesMk_card_countRestricted body changedL84–90
84 HasProd (fun i ↦ ∑ j ∈ range m, X ^ ((i + 1) * j))
85 (PowerSeries.mk fun n ↦ (#(countRestricted n m) : R)) := by
86 nontriviality R using Subsingleton.eq_one (α := R⟦X⟧)
− convert hasProd_genFun (fun i c ↦ if c < m then (1 : R) else 0) using 1
87 convert hasProd_genFun' (fun i c ↦ if c < m then (1 : R) else 0) using 1
88 · ext1 i
89 rw [sum_range_eq_add_Ico _ hm, sum_Ico_eq_sum_range]
90 congrm $(by simp) + ?_
0/27 declarations checked

Your review, as Markdown

Paste it as a comment or a review on the PR. Line links to the head commit unfold into code snippets on GitHub.