leanprover / leanprover/lean4

Should `.below` be marked as private/internal?

Open
#4,701 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

See for example

#check List.Sublist.below.cons
List.Sublist.below.cons.{u_1} {α : Type u_1} :
  ∀ {motive : (a a_1 : List α) → a.Sublist a_1 → Prop} {l₁ l₂ : List α} (a : α) {a_1 : l₁.Sublist l₂},
    a_1.below → motive l₁ l₂ a_1 → ⋯.below

In tests/lean/run/constructor_as_variable.lean we now see the error:

error: invalid pattern, constructor or constant marked with '[match_pattern]' expected

Suggestions: 'List.Sublist.below.cons', 'List.Sublist.cons', 'List.cons'

on the test

def ctorSuggestion2 (list : List α) : Nat :=
  match list with
  | nil => 0
  | cons x xs => 1 + ctorSuggestion2 xs

These .below auxiliary functions are rarely (never?) meant to be used by users, and perhaps should be marked as private or internal in some way, so they would not be displayed here.

There is already a check for isPrivateName when generating this message.

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

Read src/Lean/Elab/PatternVar.lean, especially the existing isPrivateName check, and reproduce the diagnostic with tests/lean/run/constructor_as_variable.lean. Determine how the .below auxiliary functions should be classified, then verify that constructor suggestions no longer display them while retaining useful suggestions such as List.cons.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.