induction does not populate instance-implicit arguments
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Prerequisites
Please put an X between the brackets as you perform the following steps:
- Check that your issue is not already filed:
https://github.com/leanprover/lean4/issues - Reduce the issue to a minimal, self-contained, reproducible test case.
Avoid dependencies to Mathlib or Batteries. - Test your test case against the latest nightly release, for example on
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
The induction tactic does not handle instance-implicit arguments, as it treats them as regular implicits.
Context
Steps to Reproduce
- Run the following:
class Foo (α : Type)
instance : Foo Nat where
@[elab_as_elim]
def Foo.induction_no (P : ∀ (α : Type) [Foo α], Prop) (nat : P Nat) (α : Type) [ohno : Foo α] : P α := sorry
@[elab_as_elim]
def Foo.induction_ok (P : ∀ (α : Type) [Foo α], Prop) (nat : P Nat) (α : Type) (ohok : Foo α) : P α := sorry
example (α : Type) [Foo α] : α = Nat := by
induction α using Foo.induction_no with
| nat => rfl
example (α : Type) [Foo α] : α = Nat := by
induction α, ‹Foo α› using Foo.induction_ok with
| nat => rfl
Expected behavior: Both inductions should succeed
Actual behavior: The first one fails with "failed to infer implicit target ohno". It should be synthesizing the target via typeclass search, since it is in square brackets.
Versions
- 4.8.0-rc1
- 4.9.0-nightly-2024-05-21
Additional Information
[Additional information, configuration or data that might be necessary to reproduce the issue]
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
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
Start by running the minimal Lean reproduction with Foo.induction_no and Foo.induction_ok, focusing on the induction tactic's handling of instance-implicit arguments. Done means both example inductions succeed, with the first target instance synthesized through typeclass search rather than failing to infer ohno.
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
- 45/100