Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

induction does not populate instance-implicit arguments #4246

Open
3 tasks
eric-wieser opened this issue May 21, 2024 · 2 comments
Open
3 tasks

induction does not populate instance-implicit arguments #4246

eric-wieser opened this issue May 21, 2024 · 2 comments
Labels
bug Something isn't working P-low We are not planning to work on this issue

Comments

@eric-wieser
Copy link
Contributor

eric-wieser commented May 21, 2024

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

The induction tactic does not handle instance-implicit arguments, as it treats them as regular implicits.

Context

Zulip thread

Steps to Reproduce

  1. 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.

@eric-wieser eric-wieser added the bug Something isn't working label May 21, 2024
@leanprover-bot leanprover-bot added the P-low We are not planning to work on this issue label Aug 23, 2024
@Kha
Copy link
Member

Kha commented Aug 26, 2024

@eric-wieser or others: could you say more about the (positive) impact of fixing this bug? Has it come up more often than with the single theorem mentioned on Zulip?

@eric-wieser
Copy link
Contributor Author

I think probably it does only come up with the handful of theorems mentioned on Zulip, but only because it is rare to have an induction principle that inducts on a typeclass argument. Finiteness is precisely the case where this is most likely to happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-low We are not planning to work on this issue
Projects
None yet
Development

No branches or pull requests

3 participants