Skip to content

feat(partitions): generalized pentagonal numbers.#31156

Closed
BeibeiX0 wants to merge 1633 commits intoleanprover-community:masterfrom
BeibeiX0:generalized_pentagonal_numbers
Closed

feat(partitions): generalized pentagonal numbers.#31156
BeibeiX0 wants to merge 1633 commits intoleanprover-community:masterfrom
BeibeiX0:generalized_pentagonal_numbers

Conversation

@BeibeiX0
Copy link
Copy Markdown
Contributor

@BeibeiX0 BeibeiX0 commented Nov 1, 2025

feat(partitions): generalized pentagonal numbers and error term eₙ

Introduce infrastructure around Euler’s pentagonal number theorem:

  • Define parity counters for strict partitions:

    • p_even_distinct n
    • p_odd_distinct n
    • strict_partitions_parity_diff n := (p_even_distinct n : ℤ) - (p_odd_distinct n : ℤ)
  • Generalized pentagonal numbers:

    • generalizedPentagonalZ : ℤ → ℤ with basic API (gpn_nonneg, gpn_coe)
    • generalizedPentagonalNum : ℤ → ℕ
    • parity lemma even_neg_j_add_three_j_sq and even_neg_j_add_three_j_sq'
    • search window equivalence exists_j_iff_exists_j_in_range
    • Decidable (∃ j : ℤ, n = generalizedPentagonalZ j) via a bounded range
  • Euler error term:

    • error_term_e n : ℤ (≔ (-1)^{|j|} if n = generalizedPentagonalZ j for some j,
      and 0 otherwise)
  • Finite product cut-off of the generating function:

    • E n : PowerSeries ℤ := ∏_{k=1}^{n+1} (1 - X^k)
    • lemma coeff_E_eq_coeff_cutoff

Implementation notes:

  • Keep the integer-valued version generalizedPentagonalZ for arithmetic lemmas and
    signs; obtain the natural-number version via Int.toNat.
  • The bounded search lemma gives a small window j ∈ [-(n+1), n+1] for decidability.

Motivation:

  • This is groundwork for proofs of Euler’s pentagonal number theorem and parity
    identities relating strict partitions to the error term.

References:

@github-actions github-actions bot added new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! t-combinatorics Combinatorics labels Nov 1, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 1, 2025

PR summary 50468bbd01

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Combinatorics.Enumerative.PentagonalNumbers (new file) 1505

Declarations diff

+ E
+ coeff_E_eq_coeff_cutoff
+ error_term_e
+ even_neg_j_add_three_j_sq
+ even_neg_j_add_three_j_sq'
+ exists_j_iff_exists_j_in_range
+ generalizedPentagonalNum
+ generalizedPentagonalZ
+ gpn_coe
+ gpn_nonneg
+ instance (n : ℕ) : Decidable (∃ j : ℤ, n = generalizedPentagonalZ j)
+ p_even_distinct
+ p_odd_distinct
+ strict_partitions_parity_diff

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/technical-debt-metrics.sh 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).

chrisflav and others added 27 commits November 2, 2025 00:43
…-community#30906)

We add constructors for isomorphisms of (pre)-`0`-hypercovers and operations relating `Presieve`s and pre-`0`-hypercovers.
…neser theorem for nonabelian groups (leanprover-community#28296)

Prove the noncommutative Freiman-Kneser theorem for doubling less than 2 - ε

Co-authored-by: strihanje01 <strihanje01@gmail.com>
Co-authored-by: Yaël Dillies <yael.dillies@gmail.com>
Consider `((Xᵢⱼ)ⱼ)ᵢ` a family of families of random variables. Assume that for any `i`, the random variables `(Xᵢⱼ)ⱼ` are independent. Assume furthermore that the random variables `((Xᵢⱼ)ⱼ)ᵢ` are independent. Then the random variables `(Xᵢⱼ)` indexed by pairs `(i, j)` are independent.

This PR also drops the `IsProbabilityMeasure` assumption from [MeasureTheory.Measure.infinitePi](https://leanprover-community.github.io/mathlib4_docs/Mathlib/Probability/ProductMeasure.html#MeasureTheory.Measure.infinitePi) to avoid weird errors with `congr`.
…ommunity#30910)

When defining a precoverage on a category, it is sometimes convenient to only define it on indexed covers. For this,
we introduce a structure `PreZeroHypercoverFamily` that is the data of a property on the pre-`0`-hypercovers of every object that is invariant under deduplication. This induces a precoverage and conversely every precoverage induces such a family.
This PR fixes several typos in `Condensed/Light/Module.lean` and `Condensed/Solid.lean`.

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
…nity#30903)

There's no such thing as ltOnePart; they're referring to leOnePart.
…nt (leanprover-community#30878)

We prove that two stochastic processes $(X\_s)\_{s \in S}$ and $(Y\_t)\_{t \in T}$ are independent if for all $s_1, ..., s_p \in S$ and $t_1, ..., t_q \in T$ the two families $(X_{s_1}, ..., X_{s_p})$ and $(Y_{t_1}, ..., Y_{t_q})$ are independent. We prove an analogous condition for a family of stochastic processes.
…eanprover-community#30820)

It is essentially `field_simp; ring1`, both of which are flexible and normalising.
Also add `ring1`, `ring1_nf` and their `!` variants as normalising: those were simply missing before.
…prover-community#30791)

This allows you to talk about Galois groups of extensions of rings without having to pass to the field of fractions. The connection with the field of fractions is given in leanprover-community#30792.

Co-authored-by: tb65536 <thomas.l.browning@gmail.com>
After this change, `min_def` has a proof term that indicates that it is an alias of `LinearOrder.min_def`. So the duplicate declaration linter will not report it.
…r-community#30923)

Neither name was great; the new one is more in line with Polynomial.leadingCoeff_map and Polynomial.leadingCoeff_map_of_leadingCoeff_ne_zero.
…munity#30930)

Add a `simp` lemma `Finset.singleton_ne_univ`, for which the corresponding `Set` lemma already exists.

```lean
@[simp] lemma singleton_ne_univ [Nontrivial α] (a : α) : {a} ≠ univ := by
```
…30929)

Add the lemma that, in a linear order with zero, two nonzero values have the same sign or opposite signs.

```lean
lemma sign_eq_sign_or_eq_neg {b : α} (ha : a ≠ 0) (hb : b ≠ 0) :
    sign a = sign b ∨ sign a = -sign b := by
```
sgouezel and others added 21 commits November 2, 2025 00:43
…#31006)

Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr>
leanprover-community#31084)

As a follow-up to PR leanprover-community#30641, uniformize the variable names in `Analysis/SpecialFunctions/Log/PosLog.lean`, for brevity and improved readability.
…nity#31127)

And document the baseSet members, as these were undocumented.

Prompted by leanprover-community#30083, i.e. transitively on the path towards geodesics and the Levi-Civita connection.
…eanprover-community#29497)

In this PR, we constructed an example of a commutative ring `A` that satisfies `ringKrullDim A = 1` but `ringKrullDim A[X] = 3`, following the construction of 

https://math.stackexchange.com/questions/1267419/examples-of-rings-whose-polynomial-rings-have-large-dimension
…anprover-community#31128)

I introduced these definitions two weeks ago without realising that there already was a naming convention for these functors.
… issues (leanprover-community#30852)

Currently the output of `lake build` and `lake build --no-build` in our build worfklows are each placed into collapsible log groups. This grouping is too coarse, since to find warnings and errors still takes scrolling or searching through potentially thousands of lines after opening the group. 

This PR adds a helper script for use in GitHub actions workflows which wraps `lake build` and groups consecutive sequences of "normal", "info", "warning" and "error" log lines into separate collapsible log groups. For examples, see:
- [grouping of trace blocks from proof widgets](https://github.com/leanprover-community/mathlib4/actions/runs/18804230623/job/53656010644#step:20:31)
- [warning and error groups in Mathlib](https://github.com/leanprover-community/mathlib4/actions/runs/18811606357/job/53673576603#step:20:31)
- [another example of warning and error groups in Mathlib](https://github.com/leanprover-community/mathlib4/actions/runs/18811662691/job/53673707777#step:20:31)

Note that while a build is in progress, lines in an open log group are still printed and visible, so this change will not make it more difficult to see how far along a build is. As mentioned above, we're already grouping log output; this change attempts to make the grouping more helpful.

The wrapper script also saves details about issues in the build (`warning`, `error`, `info` messages from `lake build`) into a JSON file for future use, e.g. determining which PR in a bors batch might have an error.

Because our build steps do not have permission to write to `GITHUB_OUTPUT`, when we invoke this wrapper, we write the build summary file to `.lake/build_summary_*.json`.

cf. [#mathlib reviewers > grouping lake build output in GitHub actions logs](https://leanprover.zulipchat.com/#narrow/channel/345428-mathlib-reviewers/topic/grouping.20lake.20build.20output.20in.20GitHub.20actions.20logs/with/546907609)

Written with help from Claude and OpenAI Codex, but checked by me.
…-community#31129)

The corresponding lemma for natural numbers already exists.
…by passing to the fraction field (leanprover-community#30792)

This PR shows that `IsGaloisGroup` is preserved by passing to the fraction field.

Co-authored-by: tb65536 <thomas.l.browning@gmail.com>
…eanprover-community#26370)

This proof was 5 years old, not in a good generality, and overly long. We fix the latter two points.
…9253)

Characterize (co)limits in preorders as glbs/lubs, plus some other instances.
…nprover-community#31116)

Add helper theorems for leanprover-community#29309

Co-authored-by: LLaurance <laurancelau.2022@berkeley.edu>
…mmunity#28797)

The relative norm of the maximal ideal `P` above the maximal ideal `p` is equal to `p ^ p.inertiaDeg P`.

Co-authored-by: Riccardo Brasca <riccardo.brasca@gmail.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
…rem (leanprover-community#31139)

We add versions of Dirichlet's theorem phrased in terms of naturals and filters, rather than ZMod, for convenience. Since these do not mention ZMod, the usual convention is to avoid use of `NeZero` and instead use an explicit hypothesis.
…atic alg. (leanprover-community#30059)

Define the norm and the star structure on a quadratic algebra.

Application to the units, the zero divisors and the field structure (when there is one).

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
…xist (leanprover-community#30901)

The action we're using to open PRs is designed to force-push over the branch it uses [by design](https://github.com/peter-evans/create-pull-request/blob/main/docs/common-issues.md#disable-force-updates-to-existing-pr-branches), but this can potentially wipe out work in progress on that branch from an existing PR. I use the same method as in [update_dependencies.yml](https://github.com/leanprover-community/mathlib4/blob/985bd66bf494c03376b6dbd2898f4873b5df6a77/.github/workflows/update_dependencies.yml#L41-L58) to only run that step if there's no open PR from the branch.

Also change the schedule to monthly, since every week might be too ambitious, given the pace of progress on leanprover-community#30759.
…ies with 11 updates (leanprover-community#31151)

Bumps the actions-version-updates group with 4 updates in the /.github directory: [dcarbone/install-jq-action](https://github.com/dcarbone/install-jq-action), [actions/checkout](https://github.com/actions/checkout), [actions/upload-artifact](https://github.com/actions/upload-artifact) and [leanprover/lean-action](https://github.com/leanprover/lean-action).
Bumps the actions-version-updates group with 11 updates in the /.github/workflows directory:

| Package | From | To |
|

Co-authored-by: Bryan Gin-ge Chen <bryangingechen@gmail.com>
…1153)

This PR updates the Mathlib dependencies.

[workflow run for this PR](https://github.com/leanprover-community/mathlib4/actions/runs/18998520409)

Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com>
@wwylele
Copy link
Copy Markdown
Collaborator

wwylele commented Nov 1, 2025

Hi, glad to see someone who is also interested in the pentagonal number theorem! I am actually in the process of upstreaming my formalization of the same theorem from https://github.com/wwylele/PentagonalNumberTheorem, and I am currently building the generating functions in #30567. Meanwhile, I didn't define the term generalizedPentagonalZ or much API for it (and just kept all the expanded formula everywhere), so I am happy to see more useful lemma for it. How do you think about a collaboration?

@BeibeiX0 BeibeiX0 closed this Nov 7, 2025
@BeibeiX0 BeibeiX0 reopened this Nov 7, 2025
@BeibeiX0
Copy link
Copy Markdown
Contributor Author

BeibeiX0 commented Nov 7, 2025

Hi, glad to see someone who is also interested in the pentagonal number theorem! I am actually in the process of upstreaming my formalization of the same theorem from https://github.com/wwylele/PentagonalNumberTheorem, and I am currently building the generating functions in #30567. Meanwhile, I didn't define the term generalizedPentagonalZ or much API for it (and just kept all the expanded formula everywhere), so I am happy to see more useful lemma for it. How do you think about a collaboration?

It’s awesome to hear that you’re working on the formalization of the Pentagonal Number Theorem!
As for collaboration, I think it would be a great opportunity to work together. I can help with formalizing the generalizedPentagonalZ term or building out more API functions and lemmas that could be useful for future work. I’d be interested in expanding on the existing formalization to ensure that the important properties and relations are covered comprehensively.
If you have specific tasks or areas that you’d like to collaborate on, feel free to share! I’d love to help out and contribute where needed.

@github-actions github-actions bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Nov 7, 2025
@BeibeiX0 BeibeiX0 force-pushed the generalized_pentagonal_numbers branch from b90619f to ef9b940 Compare November 7, 2025 14:40
@BeibeiX0 BeibeiX0 closed this Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! t-combinatorics Combinatorics

Projects

None yet

Development

Successfully merging this pull request may close these issues.