fix(scripts): add_deprecations.sh generates additive aliases for @[to_additive] decls#40237
Conversation
…_additive] decls Fixes leanprover-community#38550 When a renamed declaration is preceded by @[to_additive], also emit a deprecated alias for the additive counterpart (e.g. foo_mul -> foo_add). Uses --unified=1 to expose the attribute as a context line in the diff.
Welcome new contributor!Thank you for contributing to Mathlib! If you haven't done so already, please review our contribution guidelines, as well as the style guide and naming conventions. In particular, we kindly remind contributors that we have guidelines regarding the use of AI when making pull requests. We use a review queue to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the If you haven't already done so, please come to https://leanprover.zulipchat.com/, introduce yourself, and mention your new PR. Thank you again for joining our community. |
PR summary d173b20fc5Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
grunweg
left a comment
There was a problem hiding this comment.
Thanks for your contribution. I agree that there is a strong need for functionality like this. That said, the guessing of the new declaration's name is quite ad hoc --- I worry about this being brittle, and wonder if there's a more robust way to do this.
For instance: @adomani can we use the declaration diff data to generate these deprecations form within Lean, replacing awk (which is... not as widely known) with Lean code?
| } | ||
| # Apply standard to_additive word substitutions to convert a multiplicative declaration | ||
| # name into its additive counterpart (snake_case, matching Lean 4 / mathlib4 conventions). | ||
| function toAdditiveName(name, cmd, result) { |
There was a problem hiding this comment.
How have to determined these patterns? Taking the most common ones from to_additive? Is this list exhaustive? Are there edge cases where this produces wrong results?
Fixes #38550
When a renamed declaration is preceded by
@[to_additive], the scriptpreviously only emitted a deprecation alias for the multiplicative name.
This PR also emits one for the additive counterpart.
Changes:
git diffto--unified=1so the unchanged@[to_additive]attribute appears as a context line in the diff output
mul→add word substitutions to derive additive old/new names and
emit a second
@[deprecated] aliasExample — before:
@[deprecated (since := "2026-06-04")] alias foo_mul := bar_mul
Example — after:
@[deprecated (since := "2026-06-04")] alias foo_mul := bar_mul
@[deprecated (since := "2026-06-04")] alias foo_add := bar_add
AI disclosure: this fix was developed with Claude (claude.ai).
I understand all the changes and can explain every design decision.