Skip to content

refactor(NumberTheory): Golf 100 files#38144

Open
yuanyi-350 wants to merge 11 commits intoleanprover-community:masterfrom
yuanyi-350:NT-golf
Open

refactor(NumberTheory): Golf 100 files#38144
yuanyi-350 wants to merge 11 commits intoleanprover-community:masterfrom
yuanyi-350:NT-golf

Conversation

@yuanyi-350
Copy link
Copy Markdown
Collaborator

@yuanyi-350 yuanyi-350 commented Apr 17, 2026

This PR is an experimental project. In this PR, we use an Agent to automatically scan and attempt to simplify proofs. We hope to eventually effectively golf 100 files and avoid reinventing the wheel in mathlib.

We have chosen Mathlib/NumberTheory as the testing ground.

If this experiment is very successful and accepted by the mathlib community, we would be honored to open source it.

The relevant projects includes

This PR serves as an index. For the actual code review, please refer to the individual PRs linked below. Each of those PRs modifies only a single file to facilitate the review process.


Open in Gitpod

@github-actions github-actions bot added the large-import Automatically added label for PRs with a significant increase in transitive imports label Apr 17, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 17, 2026

PR summary 71f5543cfd

Import changes exceeding 2%

% File
+18.72% Mathlib.NumberTheory.FLT.Polynomial

Import changes for modified files

Dependency changes

File Base Count Head Count Change
Mathlib.NumberTheory.FLT.Polynomial 1405 1668 +263 (+18.72%)
Mathlib.NumberTheory.Padics.PadicNorm 931 934 +3 (+0.32%)
Mathlib.NumberTheory.Padics.Hensel 1744 1745 +1 (+0.06%)
Import changes for all files
Files Import difference
15 files Mathlib.AlgebraicGeometry.Sites.ElladicCohomology Mathlib.NumberTheory.Cyclotomic.CyclotomicCharacter Mathlib.NumberTheory.Harmonic.Int Mathlib.NumberTheory.Ostrowski Mathlib.NumberTheory.Padics.AddChar Mathlib.NumberTheory.Padics.Hensel Mathlib.NumberTheory.Padics.MahlerBasis Mathlib.NumberTheory.Padics.PadicIntegers Mathlib.NumberTheory.Padics.PadicNumbers Mathlib.NumberTheory.Padics.ProperSpace Mathlib.NumberTheory.Padics.RingHoms Mathlib.NumberTheory.Padics.ValuativeRel Mathlib.NumberTheory.Padics.WithVal Mathlib.RingTheory.DividedPowers.Padic Mathlib.RingTheory.WittVector.Compare
1
Mathlib.NumberTheory.Padics.PadicNorm 3
Mathlib.NumberTheory.FLT.Polynomial 263

Declarations diff

No declarations were harmed in the making of this PR! 🐙

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

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

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


No changes to technical debt.

You can run this locally as

./scripts/reporting/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).

@github-actions github-actions bot added the t-number-theory Number theory (also use t-algebra or t-analysis to specialize) label Apr 17, 2026
@yuanyi-350 yuanyi-350 added codex OpenAI Codex wrote (parts of) this PR. LLM-generated PRs with substantial input from LLMs - review accordingly labels Apr 17, 2026
@grunweg grunweg added the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Apr 17, 2026
@github-actions github-actions bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Apr 18, 2026
@tb65536
Copy link
Copy Markdown
Contributor

tb65536 commented Apr 18, 2026

These actually look pretty reasonable. Nice work! If you could split into smaller PRs, that would make reviewing easier and quicker (some of these are clearer improvements than others, and some will require more specialized reviewing knowledge to make sure that the new proofs are using the API in a healthy maintainable way).

Also, you should change the title of the PR to avoid scaring off reviewers :)

@mathlib-dependent-issues mathlib-dependent-issues bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Apr 18, 2026
mathlib-bors bot pushed a commit that referenced this pull request Apr 19, 2026
This PR selectively ports part of #38144 and only migrates the changes in:

- `Mathlib/NumberTheory/FactorisationProperties.lean`

Concretely, this PR:

- rewrites `Prime.not_pseudoperfect` to use `Prime.properDivisors` and `Finset.sum_le_sum_of_subset` directly, instead of analyzing the powerset of proper divisors by cases
- shortens `Prime.not_perfect` to the direct consequence of `Prime.not_pseudoperfect`
- refactors `Prime.deficient_pow` to reuse `properDivisors_prime_pow` and a simple mapped-sum identity, instead of reproving the structure of the proper divisors of a prime power inline
@mathlib-dependent-issues mathlib-dependent-issues bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Apr 20, 2026
@tb65536
Copy link
Copy Markdown
Contributor

tb65536 commented Apr 20, 2026

Can you mark this PR as depend on the other smaller PRs (so that this PR doesn't show up on queue)?

@tb65536 tb65536 added the awaiting-author A reviewer has asked the author a question or requested changes. label Apr 20, 2026
@yuanyi-350
Copy link
Copy Markdown
Collaborator Author

@tb65536 , done!

@mathlib-dependent-issues mathlib-dependent-issues bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) codex OpenAI Codex wrote (parts of) this PR. large-import Automatically added label for PRs with a significant increase in transitive imports LLM-generated PRs with substantial input from LLMs - review accordingly t-number-theory Number theory (also use t-algebra or t-analysis to specialize)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants