Skip to content

Conversation

YaelDillies
Copy link
Collaborator

@YaelDillies YaelDillies commented Oct 13, 2025

Golf many proofs using grw, gcongr, cutsat, linarith... For this, tag a few more lemmas with gcongr, and make some existing ones stronger.

The goal here is not necessarily to golf (although it usually is the case), but instead to reduce the number of explicit mentions of lemmas, as these are a maintainability concern.

The precise golfs that are performed are motivated by #30242, where four pairs of very basic and widespread lemmas get swapped. The best way to reduce the number of swaps needed is to simply not mention the lemmas explicitly.


Annoyingly, grw is basically unusable with strict inequalities (it often leaves an unprovable goal since it doesn't know about lt_of_le_of_lt nor lt_of_lt_of_le, but only lt_trans). This means that I must fall back to gcongr; exact strict_ineq many times where I would instead have liked to do grw [strict_ineq].

Open in Gitpod

Copy link

github-actions bot commented Oct 13, 2025

PR summary 2528a23415

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ GCongr.ofNat_le_ofNat
+ card_nonuniformWitnesses_le
+ repr_le_repr
+ repr_lt_repr
+ ruzsaSzemerediNumberNat_le_ruzsaSzemerediNumberNat

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

@YaelDillies YaelDillies force-pushed the more_grw_gcongr branch 5 times, most recently from 5890999 to cd8c2c8 Compare October 14, 2025 09:01
@grunweg grunweg self-assigned this Oct 15, 2025
Copy link
Collaborator

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

Thank you for doing this huge change! I reviewed the first 101 files so far (will continue later, also when you have fixed the build more). I like most of these changes, think we should benchmark this just in case, and have a few comments when I'm not as sure or need to be convinced this is good.

@mathlib4-merge-conflict-bot mathlib4-merge-conflict-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 Oct 15, 2025
@mathlib4-merge-conflict-bot
Copy link
Collaborator

This pull request has conflicts, please merge master and resolve them.

@github-actions github-actions bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Oct 16, 2025
Copy link
Collaborator

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

Reviewed the rest (except for 5 files); I'll do one last pass when you have fixed the build and my comments so far. Thanks a lot for doing this!

@grunweg
Copy link
Collaborator

grunweg commented Oct 16, 2025

Assuming CI is happy, I have no further review comments than the ones above. Let's benchmark this and then merge soon!

@YaelDillies
Copy link
Collaborator Author

I believe I have replied to all your comments, or rather exhibited a section of answers from the equivalence class of comments. Let's bench too:

!bench

@grunweg
Copy link
Collaborator

grunweg commented Oct 16, 2025

!bench

@grunweg
Copy link
Collaborator

grunweg commented Oct 16, 2025

IIRC, the bot only picks up comments which contain this exact string, and nothing else.

@grunweg
Copy link
Collaborator

grunweg commented Oct 16, 2025

@JovanGerb Do you mind briefly checking the new gcongr lemmas introduced in this PR? I'm pretty sure they're fine, but don't know if there's anything that could go wrong. Thank you!

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit dd3f9dd.
There were no significant changes against commit 6b1d0f0.

Copy link

File Instructions %
build -572.449⬝10⁹ (-0.35%)
lint -144.94⬝10⁹ (-2.18%)
Mathlib.Data.Nat.Dist +3.888⬝10⁹ (+52.99%)
Mathlib.Algebra.MvPolynomial.Degrees +2.442⬝10⁹ (+8.23%)
4 files, Instructions +1.0⬝10⁹
File Instructions %
Mathlib.Probability.Kernel.Disintegration.Basic +1.967⬝10⁹ (+14.56%)
Mathlib.AlgebraicGeometry.ProjectiveSpectrum.Proper +1.805⬝10⁹ (+2.42%)
Mathlib.NumberTheory.AbelSummation +1.306⬝10⁹ (+3.36%)
Mathlib.Analysis.Normed.Operator.NNNorm +1.53⬝10⁹ (+3.74%)
File Instructions %
Mathlib.Tactic.Common -1.59⬝10⁹ (-21.34%)
Mathlib.MeasureTheory.Function.SimpleFuncDenseLp -2.216⬝10⁹ (-2.05%)
CI run Lakeprof report

Copy link
Collaborator

@JovanGerb JovanGerb left a comment

Choose a reason for hiding this comment

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

Thanks for making this PR. Most gcongr tags look good, I only suggest a change for the opow one.

| n + 1 => by rw [sqrtTwoAddSeries, sqrtTwoAddSeries_succ _ _, sqrtTwoAddSeries]

@[gcongr]
theorem sqrtTwoAddSeries_monotone_left {x y : ℝ} (h : x ≤ y) :
Copy link
Collaborator

Choose a reason for hiding this comment

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

The lemma name should say mono instead of monotone, but I guess that's not for this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's make that a follow-up PR!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Feel free to open a PR, Jovan :)

alias isLimit_opow_left := isSuccLimit_opow_left

@[gcongr]
theorem opow_le_opow_right {a b c : Ordinal} (h₁ : 0 < a) (h₂ : b ≤ c) : a ^ b ≤ a ^ c := by
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest tagging opow_le_opow instead of the right version, as it is more general.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As Heather explained, gcongr needs both (use case being monotonicity of multiplication). I'll tag opow_le_opow too

Copy link
Collaborator

Choose a reason for hiding this comment

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

I claim that if you tag opow_le_opow, then you can safely drop the tag from the right version

Copy link
Collaborator

Choose a reason for hiding this comment

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

If Heather explained otherwise, then that explanation is now out of date.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, I wasn't aware you had made the change to gcongr. That would have been good to mention the first time around!

@grunweg
Copy link
Collaborator

grunweg commented Oct 17, 2025

Thanks for the quick review, Jovan! With the benchmark results being in, I'm happy this PR with all "somewhat controversial parts removed". If you

  • remove the instance removal
  • remove the \forall changes from this PR,

I'll merge the rest directly. Optionally, waiting on a zulip consensus on the style guide thread is another option.

@YaelDillies
Copy link
Collaborator Author

See #30632

@grunweg
Copy link
Collaborator

grunweg commented Oct 17, 2025

Thank you for the prompt response and agreeing to split this PR. This subset of changes looks uncontroversial, so I'm happy to merge it directly (once CI has finished).

@grunweg
Copy link
Collaborator

grunweg commented Oct 17, 2025

bors merge

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the ready-to-merge This PR has been sent to bors. label Oct 17, 2025
@JovanGerb
Copy link
Collaborator

opow_le_opow_right is still unnecessarily tagged with @[gcongr]

@grunweg
Copy link
Collaborator

grunweg commented Oct 17, 2025

Sorry for that. Would you like to make a follow-up PR; if it builds, I'll happily merge it!

mathlib-bors bot pushed a commit that referenced this pull request Oct 17, 2025
Golf many proofs using `grw`, `gcongr`, `cutsat`, `linarith`... For this, tag a few more lemmas with `gcongr`, and make some existing ones stronger.

The goal here is not necessarily to golf (although it usually is the case), but instead to reduce the number of explicit mentions of lemmas, as these are a maintainability concern.

The precise golfs that are performed are motivated by #30242, where four pairs of very basic and widespread lemmas get swapped. The best way to reduce the number of swaps needed is to simply not mention the lemmas explicitly.
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Oct 17, 2025

Build failed (retrying...):

mathlib-bors bot pushed a commit that referenced this pull request Oct 17, 2025
Golf many proofs using `grw`, `gcongr`, `cutsat`, `linarith`... For this, tag a few more lemmas with `gcongr`, and make some existing ones stronger.

The goal here is not necessarily to golf (although it usually is the case), but instead to reduce the number of explicit mentions of lemmas, as these are a maintainability concern.

The precise golfs that are performed are motivated by #30242, where four pairs of very basic and widespread lemmas get swapped. The best way to reduce the number of swaps needed is to simply not mention the lemmas explicitly.
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Oct 17, 2025

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title chore: use grw, gcongr more [Merged by Bors] - chore: use grw, gcongr more Oct 17, 2025
@mathlib-bors mathlib-bors bot closed this Oct 17, 2025
@YaelDillies YaelDillies deleted the more_grw_gcongr branch October 17, 2025 15:41
mathlib-bors bot pushed a commit that referenced this pull request Oct 18, 2025
This tag was accidentally added in #30508, but it is redundant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR has been sent to bors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants