chore(scripts): handle simple to_additive deprecations#38635
chore(scripts): handle simple to_additive deprecations#38635Fieldnote-Echo wants to merge 1 commit intoleanprover-community:masterfrom
Conversation
…renames When a renamed declaration carries `@[to_additive]`, emit the additive deprecation alias first, followed by the multiplicative alias tagged `@[to_additive existing, deprecated ...]` so the additive deprecation is rederived through the to_additive machinery. Detection uses an --unified=3 diff so awk can read the attribute from context lines. The additive name is computed by a small substitution table (mul/add, prod/sum, one/zero, inv/neg, div/sub) over declaration- name tokens; typeclass prefixes are not renamed. When the substituted name still contains `Monoid`/`Group`/`Semigroup` without an `Add` prefix, the additive alias is skipped — those renames are left for manual deprecation rather than emitting a name that does not exist. Adding or removing `@[to_additive]` in the rename does not trigger an additive alias (regex anchored to context lines). `@[to_additive_relevant_arg]` is rejected by an identifier boundary. The first-comma-only split in addDeprecations preserves commas inside the deprecation text. Closes leanprover-community#38550.
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 35aa1b8156Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
Closes #38550.
This updates
scripts/add_deprecations.shso that, when a renamed declaration is near an existing@[to_additive]attribute, the script also emits the additive deprecation alias in the common default-name case.For example,
foo_mul -> bar_mulnow produces:This is intentionally conservative and text-based, matching the existing script. It handles common name translations such as mul/add, prod/sum, one/zero, inv/neg, and div/sub, and skips cases that look like they need less common to_additive name generation.
Tested with a local six-case fixture and a scratch Lean file confirming that the generated alias form compiles and produces deprecation warnings for both names.
I opened this as draft because I still count as a new contributor under the LLM-assisted PR policy. I have one merged mathlib PR (#36443), and this is a one-file script patch that I reviewed/tested manually. I'll leave it as draft unless a maintainer gives it the green light to flip ready.
I used Claude assistance while drafting and testing the patch. I reviewed the final diff manually and tested the generated Lean form locally.