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: do not report metaprogramming declarations via exact? and rw? #6672

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kim-em
Copy link
Collaborator

@kim-em kim-em commented Jan 16, 2025

This PR filters out all declarations from Lean.*, *.Tactic.*, and *.Linter.* from the results of exact? and rw?.

@kim-em kim-em added the changelog-library Library label Jan 16, 2025
@kim-em kim-em requested a review from leodemoura as a code owner January 16, 2025 22:34
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc January 16, 2025 22:49 Inactive
@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 Jan 16, 2025
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase f01527142e1df55c060b9abb6a36b3606ffa6ada --onto f4c9934171a22d376fb7c318ce2dcf80ab0eaf0e. (2025-01-16 23:00:38)

@kim-em kim-em changed the title feat: do not report Lean internals via exact? and rw? feat: do not report metaprogramming declarations via exact? and rw? Jan 16, 2025
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc January 16, 2025 23:21 Inactive
@kim-em kim-em added changelog-language Language features, tactics, and metaprograms and removed changelog-library Library labels Jan 17, 2025
@nomeata
Copy link
Collaborator

nomeata commented Jan 17, 2025

This conflicts a bit of using Lean.Order for a theory that is not general purpose (hence the name Lean) and really only for one feature partial_fixpoint, but it is meant to be extensible by users who may have to prove theorems.

As a pragmatic compromise, could isMetaprogramming live in CoreM and do not filter out names from explicitly opened namespaces? If I am in open Lean.Order, then I’m probably interested in these lemmas.

Or I change my naming convention in #6355 to something else.

@nomeata
Copy link
Collaborator

nomeata commented Jan 17, 2025

Another way to shave the cat:

We introduce an way to mark namespaces (not names) as “hidden”. This annotation should convey that contents of the namespace should not show up in search results, autocompletion etc., unless that namespaces is explicitly opened. This would also work well for Lean.Grind, can be used by libraries, and it a bit more precise than my previous suggestion (where a blunt open Lean might already unhide too much).

@kim-em
Copy link
Collaborator Author

kim-em commented Jan 17, 2025

I suspect for exact? at least we'd have to plumb things differently to respect open namespaces, as we couldn't be looking that up for each declaration. But it would be doable.

If it's possible to just use the Lean.* boundary, I'd prefer that...

@nomeata
Copy link
Collaborator

nomeata commented Jan 17, 2025

I suspect for exact? at least we'd have to plumb things differently to respect open namespaces, as we couldn't be looking that up for each declaration. But it would be doable.

Is this filtering just for presentation or also for the search? I.e. could you filter the successful results and maybe even include a hint (“some results from hidden namespaces were omitted“). That may be both good (users find a proof, and can copy some theorem or ask for a public one) and bad (users enable +hidden and use the internal proof again).

If it's possible to just use the Lean.* boundary, I'd prefer that...

Ok. If we are doing ad-hoc things I can ex-exclude Lean.Order when I land that :-)

@@ -184,6 +184,11 @@ def anyS (n : Name) (f : String → Bool) : Bool :=
| .num p _ => p.anyS f
| _ => false

/-- Return true if the name is in a namespace associated to metaprogramming.-/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/-- Return true if the name is in a namespace associated to metaprogramming.-/
/-- Return true if the name is in a namespace associated to metaprogramming. -/

/-- Return true if the name is in a namespace associated to metaprogramming.-/
def isMetaprogramming (n : Name) : Bool :=
let components := n.components
components.head? == `Lean || (components.any fun n => n == `Tactic || n == `Linter)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The environment linters in Batteries use Batteries.Tactic.Lint as part of their namespace: they get excluded by Tactic, but maybe you could

  • also filter Lint here, or
  • change their namespace to Linter instead of Lint.

@@ -275,3 +275,9 @@ error: apply? didn't find any relevant lemmas
-/
#guard_msgs in
example {α : Sort u} (x y : α) : Eq x y := by apply?

-- If this lemmas is added later to the library, please update this `#guard_msgs`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- If this lemmas is added later to the library, please update this `#guard_msgs`.
-- If this lemma is added later to the library, please update this `#guard_msgs`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-language Language features, tactics, and metaprograms 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.

4 participants