leanprover-community / leanprover-community/lean

Type-class search fails for `∀ [foo], bar`

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

Nobody has claimed this yet.

Dominant language
C++
Stars
434
Forks
79
PR merge metrics
No merged PRs in 30d

Description

class foo (n : ℕ) : Prop :=
(has_true : true)

class bar (n : ℕ) : Prop :=
(has_true : true)

@[reducible] def quux := ∀ n [foo n], bar n

lemma have_quux : quux := by intros n h; constructor; constructor

example [quux] : quux := by apply_instance
example [∀ n [foo n], bar n] : quux := by apply_instance
example [∀ n [foo n], bar n] : ∀ n [foo n], bar n := by apply_instance
example [∀ n [foo n], bar n] (n) [foo n] : bar n := by apply_instance
example [quux] (n) [foo n] : bar n := by apply_instance

I'm not sure if we should/can fix this in general because it conflicts with the frozen instances policy. Although in this case here it could be solved via unification.

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 by running the supplied Lean reproducer and examining the type-class search behavior for the quantified instance forms. The issue raises a possible unification-based fix but also a conflict with the frozen instances policy, so first establish the intended policy and scope with maintainers. Done means an agreed behavior is implemented and the examples have appropriate regression coverage.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.