Skip to content

feat(Tactic/Alias): let attributes know that the constant is an alias#1763

Open
JovanGerb wants to merge 3 commits intoleanprover-community:mainfrom
JovanGerb:Jovan-alias-attrs
Open

feat(Tactic/Alias): let attributes know that the constant is an alias#1763
JovanGerb wants to merge 3 commits intoleanprover-community:mainfrom
JovanGerb:Jovan-alias-attrs

Conversation

@JovanGerb
Copy link
Copy Markdown
Contributor

When tagging an alias with to_additive, we would like to have the translated declaration also be an alias, and have it get the docstring that normal aliases get. To do this, we need alias to first tag the declaration as an alias before elaborating the attributes.

I noticed that the aliasExt extension was not actually storing aliases how they appear, but some funny kind of transitive extension of this. This is annoying, because this is not what is used for the generated docstring. Hence, I've changed this so that the environment extension stores the aliases how they are written down. If desired, it is always possible to compute a transitive closure of this.

@github-actions github-actions bot added the awaiting-review This PR is ready for review; the author thinks it is ready to be merged. label Apr 8, 2026
mathlib-nightly-testing bot added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Apr 8, 2026
@fgdorais
Copy link
Copy Markdown
Collaborator

I wrote this three years ago, adapting Mario's code for the old alias command. Mario insisted that the aliasExt references the root alias instead of the (given) head alias. I thought it best for the docstring to be generated from the head alias. We were to revisit these choices when users found them inconvenient. This is finally the day! Three years seems long but I suspect chains of aliases are relatively rare.

Yes, the two decisions are incompatible with each other. Interestingly, nothing breaks after your change. However, this doesn't mean there aren't any downstream tools that rely on the current behavior. For prudence, let's have two versions of getAliasInfo: getRootAliasInfo for the old behavior, getHeadAliasInfo for the new behavior. Then let's deprecate getAliasInfo to getRootAliasInfo. That way any existing tools will be easy to fix (unless they rely directly on the aliasExt, which they shouldn't do anyway).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review This PR is ready for review; the author thinks it is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants