leanprover-community / leanprover-community/lean
Implicit arguments in structure fields are not respected when using projection notation
Open
Nobody has claimed this yet.
bug
- Dominant language
- C++
- Stars
- 434
- Forks
- 79
- PR merge metrics
- No merged PRs in 30d
Description
For some reason structure fields are not elaborated the same as other definitions when using projection notation, even when all the binder types and attributes are the same:
class foo (α : Type) : Type := (f : α)
def foo.f' {α : Type} [c : foo α] : α := foo.f
#print foo.f -- def foo.f : Π {α : Type} [c : foo α], α
#print foo.f' -- def foo.f' : Π {α : Type} [c : foo α], α
variables {α : Type} [c : foo α]
#check c.f -- ok, should fail
#check c.f' -- fail
structure bar : Prop := (f : ∀ {m : ℕ}, m = 0)
def bar.f' : bar → ∀ {m : ℕ}, m = 0 := bar.f
#print bar.f -- def bar.f : bar → ∀ {m : ℕ}, m = 0
#print bar.f' -- def bar.f' : bar → ∀ {m : ℕ}, m = 0
variables (h : bar) (m : ℕ)
#check (h.f : ∀ {m : ℕ}, m = 0) -- ok
#check (h.f : m = 0) -- fail
#check (h.f m : m = 0) -- fail
#check (h.f' : m = 0) -- ok
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Lean snippets in the issue and compare the elaboration of structure-field projection with the corresponding definitions. Trace the projection-notation behavior until the differing treatment of implicit arguments is identified; done when the shown checks and expected failures behave consistently.
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
- Mostly clear
- Newbie friendliness
- 35/100