leanprover-community / leanprover-community/lean

Implicit arguments in structure fields are not respected when using projection notation

Open
#492 0 comments 0 reactions 0 assignees View on GitHub

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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.