Skip to content

refactor(NumberTheory): golf Mathlib/NumberTheory/Dioph#38457

Open
yuanyi-350 wants to merge 2 commits intoleanprover-community:masterfrom
yuanyi-350:N_9
Open

refactor(NumberTheory): golf Mathlib/NumberTheory/Dioph#38457
yuanyi-350 wants to merge 2 commits intoleanprover-community:masterfrom
yuanyi-350:N_9

Conversation

@yuanyi-350
Copy link
Copy Markdown
Collaborator

  • golfs Mathlib/NumberTheory/Dioph by replacing the arithmetic proof in sub_dioph with grind
  • simplifies div_dioph by splitting on y = 0 ∨ 0 < y, then closing the positive case with Nat.div_eq_iff and grind

Extracted from #38144

Open in Gitpod

@yuanyi-350 yuanyi-350 added t-number-theory Number theory (also use t-algebra or t-analysis to specialize) codex OpenAI Codex wrote (parts of) this PR. LLM-generated PRs with substantial input from LLMs - review accordingly labels Apr 24, 2026
@yuanyi-350
Copy link
Copy Markdown
Collaborator Author

!bench

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 24, 2026

PR summary 7705510fbc

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

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.

This script lives in the mathlib-ci 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.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).

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Apr 24, 2026

Benchmark results for 14367bd against 7705510 are in. No significant results found. @yuanyi-350

  • 🟥 build//instructions: +6.6G (+0.00%)

No significant changes detected.

@grunweg grunweg added the awaiting-author A reviewer has asked the author a question or requested changes. label Apr 24, 2026
@grunweg
Copy link
Copy Markdown
Contributor

grunweg commented Apr 24, 2026

Feel free to remove the label once you have commented on the performance!

@yuanyi-350
Copy link
Copy Markdown
Collaborator Author

I ran a profiler comparison for the changed declarations in this PR.

Results (seconds):

  • Dioph.sub_dioph: 0.048198 -> 0.056772 (+17.79%)
  • Dioph.div_dioph: 0.053122 -> 0.094187 (+77.30%)

Overall:

  • both changed declarations got slower in this measurement, with a small regression in Dioph.sub_dioph and a larger regression in Dioph.div_dioph

@yuanyi-350 yuanyi-350 removed the awaiting-author A reviewer has asked the author a question or requested changes. label Apr 24, 2026
Copy link
Copy Markdown
Contributor

@grunweg grunweg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the proofs are an improvement --- and would justify the minor performance loss.

(le_antisymm_iff.trans <| and_congr (Nat.le_div_iff_mul_le ypos) <|
Iff.trans ⟨lt_succ_of_le, le_of_lt_succ⟩ (div_lt_iff_lt_mul ypos)).symm
rcases y.eq_zero_or_pos with rfl | hy
· simp [eq_comm]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need eq_comm here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simp can simplify this expression to z = 0 ↔ 0 = z, and then eq_comm is needed.

Comment thread Mathlib/NumberTheory/Dioph.lean Outdated
@grunweg grunweg added the awaiting-author A reviewer has asked the author a question or requested changes. label Apr 24, 2026
@yuanyi-350 yuanyi-350 removed the awaiting-author A reviewer has asked the author a question or requested changes. label Apr 25, 2026
@yuanyi-350 yuanyi-350 requested a review from grunweg April 25, 2026 01:48
@grunweg
Copy link
Copy Markdown
Contributor

grunweg commented Apr 25, 2026

Thanks!
maintainer merge

@github-actions
Copy link
Copy Markdown

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

@mathlib-triage mathlib-triage Bot added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex OpenAI Codex wrote (parts of) this PR. LLM-generated PRs with substantial input from LLMs - review accordingly maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. 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.

4 participants