leanprover / leanprover/lean4

RFC: Attributes in `#print`

Open
#6,107 4 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P-medium RFC
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Proposal

In Lean 3, #print would show the attributes on a definition, such as @[reducible] or @[simp]. We should get this back. I think the only blocker here is a technical one.

@[reducible, simp] def foo := 1

#print foo
-- @[reducible] def Lean.Compiler.foo : Nat :=
-- 1

Currently a few attributes like @[reducible] are supported, but not others like @[simp], as demonstrated above.

Because the interest of #print is in seeing how lean views a declaration (and not merely copying the text of the input), I suggest this shows attributes relevant at the time of use, not the time of declaration. (In any case, in lean it is difficult to implement the latter.) The implementation in #6115 does not show scoped and local for attributes, and it does not show attributes at all if they were local and are now out of scope. These are both due to implementation issues, but the former seems easier to fix than the latter.

Community Feedback

This comes up periodically on Zulip, here is the latest thread.

Impact

Add 👍 to issues you consider important. If others benefit from the changes in this proposal being added, please ask them to add 👍 to it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin with the #print behavior described here and compare it with the implementation in #6115; no source file or test is identified in the issue. Done means #print shows applicable attributes such as reducible and simp, with the scoped and local behavior resolved as specified.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.