Skip to content

[Merged by Bors] - chore: golf using grind#34423

Closed
euprunin wants to merge 6 commits intoleanprover-community:masterfrom
euprunin:golf-dxc
Closed

[Merged by Bors] - chore: golf using grind#34423
euprunin wants to merge 6 commits intoleanprover-community:masterfrom
euprunin:golf-dxc

Conversation

@euprunin
Copy link
Copy Markdown
Contributor

@euprunin euprunin commented Jan 25, 2026

The goal of this golfing PR is to decrease the number of times lemmas are called explicitly (replacing calls to lemmas with calls to tactics). Any decrease in compilation time is a welcome side effect, although it is not a primary objective.

Trace profiling results (shown if ≥10 ms before or after):

  • LucasLehmer.norm_num_ext.sModNat_eq_sMod: 950 ms before, 758 ms after 🎉

This golfing PR is batched under the following guidelines:

  • Up to ~5 changed files per PR
  • Up to ~25 changed declarations per PR
  • Up to ~100 changed lines per PR

Open in Gitpod

@euprunin euprunin changed the title chore: golf using grind and add grind annotation chore: golf using grind Jan 25, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 25, 2026

PR summary 69cbc416b3

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.

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).

@euprunin euprunin changed the title chore: golf using grind chore: golf using grind and add grind annotation Jan 25, 2026
@euprunin
Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Jan 29, 2026

Benchmark results for 81f5e3a against 899a433 are in! @euprunin

  • 🟥 build//instructions: +2.0G (+0.0%)

No significant changes detected.

@euprunin
Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Feb 12, 2026

Benchmark results for f622b49 against 899a433 are in! @euprunin

  • build//instructions: -98.9G (-0.05%)

Small changes (2✅, 18🟥)

  • 🟥 build/module/Aesop.ElabM//instructions: +280.1M (+10.35%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.Exception//instructions: +253.1M (+8.77%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.Frontend.Basic//instructions: +213.5M (+8.49%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.Index.DiscrTreeConfig//instructions: +299.1M (+12.09%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.Options.Public//instructions: +322.0M (+7.63%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.RuleSet.Name//instructions: +238.7M (+9.99%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.RuleTac.FVarIdSubst//instructions: +279.4M (+8.69%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.Script.GoalWithMVars//instructions: +277.2M (+10.74%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.Script.OptimizeSyntax//instructions: +267.8M (+6.87%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.Script.Tactic//instructions: +253.5M (+10.16%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.Util.Tactic.Unfold//instructions: +76.8M (+1.80%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.Util.Tactic//instructions: +64.8M (+2.49%)
  • 🟥 build/module/Aesop.Util.Unfold//instructions: +277.4M (+6.16%) (reduced significance based on absolute threshold)
  • build/module/Mathlib.Order.FixedPoints//instructions: -732.7M (-4.51%)
  • 🟥 build/module/Mathlib.Tactic.Recover//instructions: +402.4M (+9.13%)
  • build/module/Mathlib.Tactic.SudoSetOption//instructions: -258.4M (-7.52%)
  • 🟥 build/module/Qq.ForLean.Do//instructions: +301.6M (+10.28%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Qq.ForLean.ReduceEval//instructions: +295.3M (+8.06%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Qq.ForLean.ToExpr//instructions: +296.9M (+9.67%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Qq.Typ//instructions: +317.6M (+11.07%) (reduced significance based on absolute threshold)

@euprunin
Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-radar
Copy link
Copy Markdown

Benchmark results for f622b49 against 899a433 are in! @euprunin

  • build//instructions: -98.9G (-0.05%)

Small changes (2✅, 18🟥)

  • 🟥 build/module/Aesop.ElabM//instructions: +280.1M (+10.35%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.Exception//instructions: +253.1M (+8.77%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.Frontend.Basic//instructions: +213.5M (+8.49%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.Index.DiscrTreeConfig//instructions: +299.1M (+12.09%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.Options.Public//instructions: +322.0M (+7.63%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.RuleSet.Name//instructions: +238.7M (+9.99%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.RuleTac.FVarIdSubst//instructions: +279.4M (+8.69%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.Script.GoalWithMVars//instructions: +277.2M (+10.74%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.Script.OptimizeSyntax//instructions: +267.8M (+6.87%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.Script.Tactic//instructions: +253.5M (+10.16%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.Util.Tactic.Unfold//instructions: +76.8M (+1.80%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Aesop.Util.Tactic//instructions: +64.8M (+2.49%)
  • 🟥 build/module/Aesop.Util.Unfold//instructions: +277.4M (+6.16%) (reduced significance based on absolute threshold)
  • build/module/Mathlib.Order.FixedPoints//instructions: -732.7M (-4.51%)
  • 🟥 build/module/Mathlib.Tactic.Recover//instructions: +402.4M (+9.13%)
  • build/module/Mathlib.Tactic.SudoSetOption//instructions: -258.4M (-7.52%)
  • 🟥 build/module/Qq.ForLean.Do//instructions: +301.6M (+10.28%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Qq.ForLean.ReduceEval//instructions: +295.3M (+8.06%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Qq.ForLean.ToExpr//instructions: +296.9M (+9.67%) (reduced significance based on absolute threshold)
  • 🟥 build/module/Qq.Typ//instructions: +317.6M (+11.07%) (reduced significance based on absolute threshold)

@euprunin
Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Feb 12, 2026

Benchmark results for 9b562ac against 899a433 are in! @euprunin

  • build//instructions: -92.4G (-0.05%)

Small changes (1🟥)

  • 🟥 build/module/Mathlib.Tactic.Recover//instructions: +399.9M (+9.08%)

@eric-wieser
Copy link
Copy Markdown
Member

eric-wieser commented Feb 13, 2026

Please make sure when writing PR descriptions that you put it above the ---, otherwise none of it ends up in the commit message.

@euprunin euprunin changed the title chore: golf using grind and add grind annotation chore: golf using grind Feb 13, 2026
@robin-carlier
Copy link
Copy Markdown
Contributor

robin-carlier commented Feb 27, 2026

I am very confused by the radar results here, because the file modified in the PR rather has a +500M change, and I really don’t get how the change here can save -92G. Can you please merge master and re-bench?

Other than that, the golf is reasonable IMO, though it does make the proof slightly less explicit. I have no strong opinion on this one and at this point one could grind it more aggressively, with something like induction k with grind [sModNat, sMod, …].

@robin-carlier robin-carlier added the awaiting-author A reviewer has asked the author a question or requested changes. label Feb 27, 2026
@euprunin
Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Feb 27, 2026

Benchmark results for ad33bd5 against 8cab065 are in! @euprunin

  • 🟥 build//instructions: +10.8G (+0.01%)

Small changes (2✅, 1🟥)

  • 🟥 build/module/Mathlib.Lean.Name//instructions: +244.5M (+7.87%)
  • build/module/Mathlib.Tactic.Coe//instructions: -391.7M (-11.49%)
  • build/module/Mathlib.Tactic.Explode.Pretty//instructions: -249.4M (-8.27%)

@euprunin
Copy link
Copy Markdown
Contributor Author

@robin-carlier Thanks for the review! Following your suggestion, I was able to golf the proof down to a single line (from 18 originally) and reduce the number of explicit lemma references to three (from 14).

@euprunin euprunin removed the awaiting-author A reviewer has asked the author a question or requested changes. label Feb 28, 2026
Copy link
Copy Markdown
Contributor

@chenson2018 chenson2018 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 this makes some good changes, but left a review concerning maintainability.

@Vierkantor
Copy link
Copy Markdown
Contributor

Thanks for the previous review!

bors d=@chenson2018

@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Apr 2, 2026

✌️ chenson2018 can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@mathlib-triage mathlib-triage bot added the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Apr 2, 2026
@chenson2018
Copy link
Copy Markdown
Contributor

bors r+

mathlib-bors bot pushed a commit that referenced this pull request Apr 2, 2026
The goal of this golfing PR is to decrease the number of times lemmas are called explicitly (replacing calls to lemmas with calls to tactics). Any decrease in compilation time is a welcome side effect, although it is not a primary objective.

Trace profiling results (shown if ≥10 ms before or after):
* `LucasLehmer.norm_num_ext.sModNat_eq_sMod`: 950 ms before, 758 ms after  🎉

This golfing PR is batched under the following guidelines:
* Up to ~5 changed files per PR
* Up to ~25 changed declarations per PR
* Up to ~100 changed lines per PR
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Apr 2, 2026

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title chore: golf using grind [Merged by Bors] - chore: golf using grind Apr 2, 2026
@mathlib-bors mathlib-bors bot closed this Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants