leanprover / leanprover/lean4

variable-notation-variable chain breaks hygiene tracking

Open
#2,535 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

From https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Notation.20introduces.20sorry/near/390699774:

variable (x : Nat)
local notation "Finx" => Fin x

def val (y : Finx) : Nat := y

variable (y : Finx)

-- Declaration uses sorry:
def val' : Nat := y

The issue is here: https://github.com/leanprover/lean4/blob/e9d60e143a8b1ee06be1f201f78068250a2b8949/src/Lean/Elab/Command.lean#L442-L449
We first elaborate all section variables as binders and then register them as such but that is wrong if one section variable references another via a notation, which is where sectionFVars is needed. We should elaborate and add them to sectionFVars one by one.

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 in src/Lean/Elab/Command.lean around lines 442-449 and reproduce the notation-based section-variable example from the issue. Trace how section variables are elaborated and registered, focusing on sectionFVars. Done means the variable chain no longer breaks hygiene tracking when one section variable references another through a local notation.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.