lean4-htt/tests/lean/run/library_suggestions_private.lean
Kim Morrison e42262e397
fix: allow private proof-valued structure fields in library suggestions (#11962)
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>
2026-01-10 08:40:54 +00:00

31 lines
1,012 B
Text

import Lean.LibrarySuggestions.Basic
/-!
# Test: Private theorems should appear in currentFile suggestions
Private theorems (declared with `private theorem`) have mangled names starting with
`_private.` which would normally be filtered by `isInternalDetail`. However, since
they're accessible from the current module, `currentFile` should include them.
-/
-- A public theorem for comparison
theorem publicTheorem : True := trivial
-- A private theorem that should still appear in currentFile suggestions
private theorem privateTheorem : 1 + 1 = 2 := rfl
-- Test the currentFile selector
set_library_suggestions Lean.LibrarySuggestions.currentFile
-- Both public and private theorems should appear.
-- The private theorem has a mangled name like `_private.library_suggestions_private.0.privateTheorem`
-- but should still be suggested since currentFile uses allowPrivate := true.
/--
info: Library suggestions:
publicTheorem
privateTheorem
-/
#guard_msgs in
example : True := by
suggestions
trivial