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: attribute delaborators #6115

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

digama0
Copy link
Collaborator

@digama0 digama0 commented Nov 18, 2024

This PR enables attributes to be able to specify how they would like to be shown in #print as additional attribute syntax, with AttributeImpl.delab being a rough inverse to AttributeImpl.add. As a result, this now works:

@[reducible, simp] def foo := 1

#print foo
-- @[reducible, simp] def foo :=
-- 1

Additional comments:

  • This does not add delaborators for every attribute; some are skipped because they leave no permanent trace, some because they don't support query at all or not efficiently enough. The semantics of the delab function are such that fun _ => pure () is always an okay backup plan.
  • In order to find places to add the new field, for now the delab field is not optional. I hope this can be used at least to clean up mathlib as well, but in the final version I expect delab to be optional and defaulted to fun _ => pure () to make it backward compatible.

Closes #6107

@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 Nov 18, 2024
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Nov 18, 2024

Mathlib CI status (docs):

  • ❗ Batteries CI can not be attempted yet, as the nightly-testing-2024-11-18 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-mathlib, Batteries CI should run now. (2024-11-18 09:00:34)
  • ❗ Mathlib CI can not be attempted yet, as the nightly-testing-2024-11-18 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-mathlib, Mathlib CI should run now. (2024-11-18 12:19:10)
  • 💥 Mathlib branch lean-pr-testing-6115 build failed against this PR. (2024-11-19 10:00:50) View Log
  • 💥 Mathlib branch lean-pr-testing-6115 build failed against this PR. (2024-11-19 10:48:07) View Log

@digama0 digama0 added changelog-language Language features, tactics, and metaprograms changelog-pp Pretty printing and removed changelog-language Language features, tactics, and metaprograms labels Nov 18, 2024
@kim-em
Copy link
Collaborator

kim-em commented Nov 19, 2024

There's now an updated nighly-with-mathlib, so if you'd like to rebase onto that we can start looking at Mathlib/Batteries.

leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Nov 19, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Nov 19, 2024
@leanprover-community-bot leanprover-community-bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label Nov 19, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Nov 19, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Nov 19, 2024
digama0 added a commit to leanprover-community/batteries that referenced this pull request Nov 19, 2024
@Kha
Copy link
Member

Kha commented Nov 22, 2024

Drafting pending acceptance of RFC

@Kha Kha marked this pull request as draft November 22, 2024 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan changelog-pp Pretty printing 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.

RFC: Attributes in #print
4 participants