leanprover / leanprover/lean4

docstrings on builtin simprocs

Open
#10,395 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Consider

-- import Lean
set_option linter.unusedSimpArgs false
example : True := by simp [BitVec.reduceEq]

hovering over the simproc it just says

A simp lemma specification is:

    optional ↑ or ↓ to specify use before or after entering the subterm
    optional ← to use the lemma backward
    thm for the theorem to rewrite with

but if I add import Lean I see the more helpful

BitVec.reduceEq : Lean.Meta.Simp.Simproc

Simplification procedure for = on BitVecs.

import Lean.Meta.Tactic.Simp.BuiltinSimprocs.BitVec

So somehow builtin simprocs don't get their docstrings show. Smells a bit like #8432, but my attempt at fixing this using

diff --git a/src/Init/Simproc.lean b/src/Init/Simproc.lean
index f188250d14..759c1a1a57 100644
--- a/src/Init/Simproc.lean
+++ b/src/Init/Simproc.lean
@@ -122,13 +122,13 @@ macro_rules
 macro_rules
   | `($[$doc?:docComment]? builtin_simproc_decl $n:ident ($pattern:term) := $body) => do
     let simprocType := `Lean.Meta.Simp.Simproc
-    `($[$doc?:docComment]? def $n:ident : $(mkIdent simprocType) := $body
+    `($[$doc?:docComment]? @[builtin_doc] def $n:ident : $(mkIdent simprocType) := $body
       builtin_simproc_pattern% $pattern => $n)
 
 macro_rules
   | `($[$doc?:docComment]? builtin_dsimproc_decl $n:ident ($pattern:term) := $body) => do
     let simprocType := `Lean.Meta.Simp.DSimproc
-    `($[$doc?:docComment]? def $n:ident : $(mkIdent simprocType) := $body
+    `($[$doc?:docComment]? @[builtin_doc] def $n:ident : $(mkIdent simprocType) := $body
       builtin_simproc_pattern% $pattern => $n)

did not help.

Version

Lean 4.24.0-nightly-2025-09-14

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

Start in src/Init/Simproc.lean and inspect how builtin_simproc_decl and builtin_dsimproc_decl expand, then trace how docstrings are collected for these declarations. Reproduce the hover behavior for BitVec.reduceEq and verify that builtin simprocs display their descriptive docstrings without requiring an explicit import.

Written by the indexing model from the issue text.

Assessment

Domain
compilers, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.