#43220 refactor(Combinatorics/Partition): eliminate T2Space requirement from generating function
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
Conversation on GitHub 18
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
relativevalue is the weighted sum of the differences with weight given by the inverse of the current value of the statistic. - The
absolutevalue is therelativevalue divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).
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>
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.
This pull request has conflicts, please merge master and resolve them.
contrapose his there any reason for this being noncomputable? also the othe noncomputable def in this file
this technically isnt the factor
expression, the factors in the second equation are defined as `Nat.Partition.genFunFactor`, and itsadd contraposition of this also?
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'] rintro ⟨_, k, rfl⟩
exact h ⟨k - 1, by grind⟩can you add a lemma connecting this with the tsum its replacing maybe? (i dont think there is one)
Something probably has changed across versions and made these computable. Let me fix them
added genFunTerm_eq_tsum
Renamed to genFunTerm
maintainer merge
🚀 Pull request has been placed on the maintainer queue by felixpernegger.
Mathlib/Combinatorics/Enumerative/Partition/Basic.lean +1 −0
def ofSymShapeEquiv (μ : Partition n) (e : σ ≃ τ) :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, \#imultiplied within one `n.Partition`, and summed among all `n.Partition` for a fitheorem tendsto_order_genFun_term_atTop_nhds_top (f : ℕ → ℕ → R) (i :theorem hasProd_genFun (f : ℕ → ℕ → R) :maybe add doc that this is to be deprecated then?
Mathlib/Combinatorics/Enumerative/Partition/Glaisher.lean +2 −2
theorem hasProd_powerSeriesMk_card_restricted [IsTopologicalSemiring R]theorem hasProd_powerSeriesMk_card_countRestricted {m : ℕ} (hm : 0 < m) :