Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: validate reducibility attribute setting #4052

Merged
merged 6 commits into from
May 3, 2024
Merged

Conversation

leodemoura
Copy link
Member

and new option set_option allowUnsafeReductibility true to override validation.

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc May 2, 2024 18:20 Inactive
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label May 2, 2024
@leanprover-community-mathlib4-bot
Copy link
Collaborator

Mathlib CI status (docs):

  • ❗ Std/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 092ca8530a6f272b7cb19235750479cdffab11de --onto 806e41151b6eb645e4ed5a40915b94b99f933564. (2024-05-02 18:25:05)

@@ -65,15 +70,75 @@ def setReducibilityStatusCore (env : Environment) (declName : Name) (status : Re
private def setReducibilityStatusImp (env : Environment) (declName : Name) (status : ReducibilityStatus) : Environment :=
setReducibilityStatusCore env declName status .global .anonymous

/-
TODO: it would be great if we could distinguish between the following two situations
Copy link
Member

Choose a reason for hiding this comment

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

Could ReducibilityHints.abbrev be used to distinguish between these cases?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately, it does not help. The key issue here is that the current attribute management system does not tell us whether an attribute is being set at a declaration time or not.

Copy link
Member

@tydeu tydeu May 2, 2024

Choose a reason for hiding this comment

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

True, having the attribute know whether it is applied at declaration time would be the best solution. However, I was proposing a potential partial solution assuming that was too complicated for now.

If I understand correctly, abbrev is just a @[reducible, inline] def with ReducibilityHints.abbrev. Thus, the primary use case for a declaring @[reducible] def over an abbrev is when the definition is meant to be reducible but not inlined. In such a case, @[noinline] abbrev could serve the same purpose. Thus, to avoid the potential for applying @[reducible] after a declaration, we could forbid @[reducible] from being applied to anything except abbrev at declaration-time (i.e., when it is semireducible). This would avoid the need to make the declaration time distinction.

Copy link
Member Author

Choose a reason for hiding this comment

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

@tydeu This is a good suggestion. Then, we would not even have the attribute [reducible]. It seems there are very few instances of @[reducible] def in Mathlib. So, the impact would be minimal. @semorrison What do you think? We can use a different PR for this change.

Copy link
Member

Choose a reason for hiding this comment

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

Fwiw, adding a flag to AttributeImpl.add that tells us whether this is a post-hoc application seems like a simple (apart from downstream breakage) and generally very useful change to me

leodemoura and others added 2 commits May 2, 2024 16:31
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc May 2, 2024 23:51 Inactive
@leodemoura leodemoura added this pull request to the merge queue May 3, 2024
Merged via the queue into master with commit 2df3536 May 3, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants