Skip to content

[Merged by Bors] - chore(Analysis/Convex/Approximation): reuse sSup_of_nat_affine_eq#37981

Closed
yuanyi-350 wants to merge 6 commits intoleanprover-community:masterfrom
yuanyi-350:golf_45
Closed

[Merged by Bors] - chore(Analysis/Convex/Approximation): reuse sSup_of_nat_affine_eq#37981
yuanyi-350 wants to merge 6 commits intoleanprover-community:masterfrom
yuanyi-350:golf_45

Conversation

@yuanyi-350
Copy link
Copy Markdown
Collaborator

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

This PR shortens the proof of univ_sSup_of_nat_affine_eq by applying the already available theorem sSup_of_nat_affine_eq to s = univ. This removes the ad hoc split on whether the family is empty, and reuses the more general result instead.

This is extracted from #37968.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 13, 2026

PR summary 1a3500f1bf

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

@github-actions github-actions bot added the t-analysis Analysis (normed *, calculus) label Apr 13, 2026
Comment thread Mathlib/Analysis/Convex/Approximation.lean Outdated
Co-authored-by: Monica Omar <23701951+themathqueen@users.noreply.github.com>
@yuanyi-350 yuanyi-350 requested a review from themathqueen April 13, 2026 10:22
@grunweg
Copy link
Copy Markdown
Contributor

grunweg commented Apr 13, 2026

Can you also comment on the performance of this change? Thanks!

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

!bench

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Apr 13, 2026

Benchmark results for c33ff46 against 1a3500f are in. No significant results found. @yuanyi-350

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

Small changes (1✅, 2🟥)

  • build/module/Mathlib.Analysis.Convex.Approximation//instructions: -1.3G (-2.03%)
  • 🟥 build/module/Mathlib.CategoryTheory.Limits.Types.Coequalizers//instructions: +393.1M (+6.55%)
  • 🟥 build/module/Mathlib.Lean.Elab.InfoTree//instructions: +125.6M (+4.95%)

Copy link
Copy Markdown
Collaborator

@themathqueen themathqueen left a comment

Choose a reason for hiding this comment

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

Thanks. I think this is fine.

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

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

Results ([Elab.definition.value], seconds, 2 runs each):

  • ConvexOn.univ_sSup_of_nat_affine_eq: first run 12.494 -> 2.607, second run 11.902 -> 3.203; average 12.198 -> 2.905 (-76.2%).

Overall:

  • This change is a clear speedup for ConvexOn.univ_sSup_of_nat_affine_eq; both runs were about 4x faster on the PR head.

Caveat:

  • The measurements were taken in isolated worktrees for the PR head and the merge-base (1a3500f1bf47ea7a2be35118599b5e5ec828b576), but they reused the current checkout's existing dependency .oleans via LEAN_PATH instead of rebuilding the full dependency graph inside each temporary worktree.

@grunweg
Copy link
Copy Markdown
Contributor

grunweg commented Apr 14, 2026

Thanks!
bors merge

@grunweg
Copy link
Copy Markdown
Contributor

grunweg commented Apr 14, 2026

As side note, 12 seconds for a single declaration is very slow --- this is suspicious (but unrelated to this PR).

mathlib-bors bot pushed a commit that referenced this pull request Apr 14, 2026
…37981)

This PR shortens the proof of `univ_sSup_of_nat_affine_eq` by applying the already available theorem `sSup_of_nat_affine_eq` to `s = univ`. This removes the ad hoc split on whether the family is empty, and reuses the more general result instead.

This is extracted from #37968.
@mathlib-triage mathlib-triage bot added the ready-to-merge This PR has been sent to bors. label Apr 14, 2026
@themathqueen
Copy link
Copy Markdown
Collaborator

themathqueen commented Apr 14, 2026

As side note, 12 seconds for a single declaration is very slow --- this is suspicious (but unrelated to this PR).

There is absolutely no way that takes 12 seconds (unless I'm misunderstanding something). It compiles almost instantly on the web editor. Could it be that they meant 0.12?

@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Apr 14, 2026

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title chore(Analysis/Convex/Approximation): reuse sSup_of_nat_affine_eq [Merged by Bors] - chore(Analysis/Convex/Approximation): reuse sSup_of_nat_affine_eq Apr 14, 2026
@mathlib-bors mathlib-bors bot closed this Apr 14, 2026
@grunweg
Copy link
Copy Markdown
Contributor

grunweg commented Apr 14, 2026

As side note, 12 seconds for a single declaration is very slow --- this is suspicious (but unrelated to this PR).

There is absolutely no way that takes 12 seconds (unless I'm misunderstanding something). It compiles almost instantly on the web editor. Could it be that they meant 0.12?

I disagree: running this locally in VS Code, I see the orange bars disappear quickly except on the declaration itself --- i.e., it is kernel checking which is taking so long. This takes several seconds on my computer, so 12 seconds seems possible.

@yuanyi-350 yuanyi-350 deleted the golf_45 branch April 19, 2026 11:53
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. t-analysis Analysis (normed *, calculus)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants