leanprover / leanprover/lean4

RFC: Lean.Name.isUserName

Open
#2,850 9 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Proposal

There's a few places in Std and Mathlib where there is a desire to filter out auto-generated and other stable names (e.g., leanprover/std4#347 and leanprover/std4#355).

I think this notion could get upstreamed in the hopes that will ensure tactics use a consistent predicate. The predicate I want is already in a test case, but could get moved to Lean/Data/Name.lean:

Hear's the addition I would propose.

/--
Return true if `declName` is a auxillary definition created by elaborator.
-/
def isAuxName : Name → Bool
| .str _ s => "match_".isPrefixOf s || "proof_".isPrefixOf s || "eq_".isPrefixOf s
| _ => false

/--
Return true if the name is a user facing name.

This returns false for names that are internal, numerical or appear auxillary created.
-/
def isUserName (declName : Name) : Bool :=
  declName.isStr
  && !declName.isAuxName
  && !declName.isInternal
Community Feedback

I haven't done this, but it's hopefully just moving a definition.

Impact

The potential impact is better consistency of ignoring definitions across tactics that want to show user facing names.

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 with the existing predicate in tests/lean/run/printDecls.lean, then inspect Lean/Data/Name.lean as the proposed destination. Compare the current test behavior with the RFC's isAuxName and isUserName proposal; done means the intended public name-filtering API is placed and its behavior is covered consistently.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.