This PR fixes library suggestions to include private proof-valued structure fields. Private proof-valued structure fields (like `private size_keys' : keys.size = values.size`) generate projections with `_private.*` mangled names. These were being filtered out by `isDeniedPremise` because `isInternalDetail` returns true for names starting with `_`. The fix allows private names through by checking `!isPrivateName name`, following the pattern from #11946. This enables `grind +suggestions` to discover and use private proof-valued structure fields from the current module. Soon I would like to fix the semantics of `isInternalDetail`, as the current behaviour is clearly wrong, but as there are many call sites, I would like to get the behaviour of tactics correct first. Also switches `currentFile` to use `wasOriginallyTheorem` instead of matching on `.thmInfo`, which correctly identifies both theorems and proof-valued projections. 🤖 Prepared with Claude Code Co-authored-by: Claude <noreply@anthropic.com>
42 lines
1 KiB
Text
42 lines
1 KiB
Text
import Lean.LibrarySuggestions.Basic
|
|
|
|
-- Define some initial local constants
|
|
def myLocalDef : Nat := 42
|
|
|
|
theorem myLocalTheorem : myLocalDef = 42 := rfl
|
|
|
|
-- Add a theorem in the Lean namespace (should be filtered by isDeniedPremise)
|
|
namespace Lean
|
|
theorem shouldBeFiltered : True := trivial
|
|
end Lean
|
|
|
|
-- Test the currentFile selector (should only show theorems, not definitions)
|
|
set_library_suggestions Lean.LibrarySuggestions.currentFile
|
|
|
|
-- First test: should show only myLocalTheorem
|
|
-- (not myLocalDef since it's a def, not Lean.shouldBeFiltered since it's in Lean namespace)
|
|
/--
|
|
info: Library suggestions:
|
|
myLocalTheorem
|
|
-/
|
|
#guard_msgs in
|
|
example : True := by
|
|
suggestions
|
|
trivial
|
|
|
|
-- Add more local constants (mix of theorems and definitions)
|
|
theorem anotherTheorem : True := trivial
|
|
|
|
def myFunction (x : Nat) : Nat := x + 1
|
|
|
|
-- Second test: should show only the two theorems (not myFunction)
|
|
/--
|
|
info: Library suggestions:
|
|
myLocalTheorem
|
|
anotherTheorem
|
|
-/
|
|
#guard_msgs in
|
|
example : False → True := by
|
|
suggestions
|
|
intro h
|
|
trivial
|