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 passes wrong instance to function application #6544

Open
3 tasks done
llllvvuu opened this issue Jan 6, 2025 · 1 comment
Open
3 tasks done

induction passes wrong instance to function application #6544

llllvvuu opened this issue Jan 6, 2025 · 1 comment
Labels
bug Something isn't working P-medium We may work on this issue if we find the time

Comments

@llllvvuu
Copy link
Contributor

llllvvuu commented Jan 6, 2025

Prerequisites

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

Description

induction will use instances on the original variable in function applications on the new variable. The tactic will succeed, and indeed create new goals, but the proof will have a type error.

Context

This was discovered during usage of https://github.com/leanprover-community/repl, where we found a successful sequence of tactics resulting in an unsuccessful proof.

Steps to Reproduce

/--
warning: declaration uses 'sorry'
---
error: application type mismatch
  @Fin.instOfNat n inst✝
argument has type
  NeZero n✝
but function has type
  [inst : NeZero n] → {i : Nat} → OfNat (Fin n) i
-/
#guard_msgs in
example (n: Nat) [NeZero n] : (0 : Fin n) = 0 := by
  induction n <;> sorry

Expected behavior: An error on the tactic as it should try to synthesize NeZero 0 and NeZero n (where the original n is succ of this n) and both should fail.

Actual behavior: The tactic uses the original NeZero n✝ instance to synthesize Fin.instOfNat, for the new (0 : Fin n), which is not type-correct. Yet the tactic does not fail.

Versions

Lean 4.16.0-rc1
Target: x86_64-unknown-linux-gnu
live.lean-lang.org

Additional Information

Initially, #4246 looked similar, but I think it's not the same.

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@llllvvuu llllvvuu added the bug Something isn't working label Jan 6, 2025
@Kha
Copy link
Member

Kha commented Jan 10, 2025

Possible workaround/explainer what step is not happening: explicitly reverting the instance works

example (n: Nat) [inst : NeZero n] : (0 : Fin n) = 0 := by
  induction n generalizing inst <;> rfl

@leanprover-bot leanprover-bot added the P-medium We may work on this issue if we find the time label Jan 10, 2025
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-medium We may work on this issue if we find the time
Projects
None yet
Development

No branches or pull requests

3 participants