Skip to content

refactor: golf CStarAlgebra/Unitization, Complex/Trigonometric, Asymptotics/SpecificAsymptotics#38075

Closed
yuanyi-350 wants to merge 5 commits intoleanprover-community:masterfrom
yuanyi-350:golf_62
Closed

refactor: golf CStarAlgebra/Unitization, Complex/Trigonometric, Asymptotics/SpecificAsymptotics#38075
yuanyi-350 wants to merge 5 commits intoleanprover-community:masterfrom
yuanyi-350:golf_62

Conversation

@yuanyi-350
Copy link
Copy Markdown
Collaborator

This PR extracts three file-level refactors from #37968 into a standalone branch:

  • Mathlib/Analysis/CStarAlgebra/Unitization.lean
  • Mathlib/Analysis/Complex/Trigonometric.lean
  • Mathlib/Analysis/Asymptotics/SpecificAsymptotics.lean

The goal is to make these simplifications reviewable independently of the larger batch PR.

@yuanyi-350 yuanyi-350 changed the title refactor: golf three analysis files refactor: golf CStarAlgebra/Unitization, Complex/Trigonometric, Asymptotics/SpecificAsymptotics Apr 15, 2026
@yuanyi-350 yuanyi-350 changed the title refactor: golf CStarAlgebra/Unitization, Complex/Trigonometric, Asymptotics/SpecificAsymptotics refactor: golf CStarAlgebra/Unitization, Complex/Trigonometric, Asymptotics/SpecificAsymptotics Apr 15, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 15, 2026

PR summary 14ec76b5f0

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 15, 2026
@themathqueen
Copy link
Copy Markdown
Collaborator

!radar

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Apr 15, 2026

Benchmark results for 2850e01 against 14ec76b are in. There are significant results. @themathqueen

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

Large changes (1🟥)

  • 🟥 build/module/Mathlib.Analysis.CStarAlgebra.Unitization//instructions: +8.2G (+20.57%)

Small changes (1✅, 1🟥)

  • build/module/Mathlib.Analysis.Asymptotics.SpecificAsymptotics//instructions: -1.8G (-10.94%)
  • 🟥 build/module/Mathlib.CategoryTheory.Limits.Shapes.IsTerminal//instructions: +771.9M (+3.58%)

Comment thread Mathlib/Analysis/CStarAlgebra/Unitization.lean Outdated
@yuanyi-350
Copy link
Copy Markdown
Collaborator Author

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

Results (seconds):

  • Asymptotics.isLittleO_pow_pow_cobounded_of_lt: 0.346176 -> 0.060680 (-82.5%)
  • Unitization.instCStarRing: 1.152755 -> 2.749847 (+138.5%)
  • Complex.cos_three_mul: 0.054808 -> 0.006588 (-88.0%)
  • Complex.sin_three_mul: 0.058487 -> 0.376893 (+544.4%)

Overall:

  • Asymptotics.isLittleO_pow_pow_cobounded_of_lt and Complex.cos_three_mul got faster.
  • Unitization.instCStarRing and especially Complex.sin_three_mul got slower.

Caveat:

  • These are single-run trace.profiler measurements of the Elab.definition.value entries after lake -R exe cache get.
  • I used the PR merge-base 14ec76b5f0 for before and PR head 2850e0138e for after.
  • I set trace.profiler.threshold := 0 for the Complex declarations so the sub-10ms entries would be reported.

Refactor sin_three_mul theorem to use sin_add and simplify expressions.
@yuanyi-350
Copy link
Copy Markdown
Collaborator Author

yuanyi-350 commented Apr 15, 2026

I have updated the PR. I removed Unitization.instCStarRing and Complex.sin_three_mul, which were severely hurting performance. Now only Asymptotics.isLittleO_pow_pow_cobounded_of_lt and Complex.cos_three_mul remain.

@themathqueen
Copy link
Copy Markdown
Collaborator

I wouldn't revert yet. Let's see what others say about it?

@yuanyi-350 yuanyi-350 requested a review from themathqueen April 16, 2026 03:24
Comment thread Mathlib/Analysis/Complex/Trigonometric.lean Outdated
@themathqueen
Copy link
Copy Markdown
Collaborator

Can you add a comment in Unitization.instCStarRing that says something like "grind works here but is slow"?

@yuanyi-350
Copy link
Copy Markdown
Collaborator Author

Can you add a comment in Unitization.instCStarRing that says something like "grind works here but is slow"?

Done.

@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 16, 2026
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.

This seems fine. I'm not too familiar with the Asymptotic files, so I'm not entirely sure for that (but it looks fine?).

If you want you can move it to a different PR along with other similar files?

rw [h₂, h₃]
/- use the definition of the norm, and split into cases based on whether the norm in the first
coordinate is bigger or smaller than the norm in the second coordinate. -/
-- `grind` works here but is much slower
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No need to add this comment.

Copy link
Copy Markdown
Collaborator

@themathqueen themathqueen Apr 16, 2026

Choose a reason for hiding this comment

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

I don't know, might be okay. Maybe it'll be faster in the future, and then we can use it? I'll leave this for other reviewers:

Suggested change
-- `grind` works here but is much slower

@grunweg
Copy link
Copy Markdown
Contributor

grunweg commented Apr 19, 2026

Please follow the requests made in the comments here and here, if still necessary. (You should still update the PR description, for instance.) Thanks!

@grunweg grunweg added the awaiting-author A reviewer has asked the author a question or requested changes. label Apr 19, 2026
@yuanyi-350 yuanyi-350 closed this Apr 20, 2026
@yuanyi-350 yuanyi-350 deleted the golf_62 branch April 20, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-author A reviewer has asked the author a question or requested changes. codex OpenAI Codex wrote (parts of) this PR. LLM-generated PRs with substantial input from LLMs - review accordingly t-analysis Analysis (normed *, calculus)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants