-
Notifications
You must be signed in to change notification settings - Fork 80
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
kernel failed to type check declaration given by rfl #76
Comments
The theorem isn't actually true by refl, and the kernel is catching it. Here's a slightly simpler example: def int.pow_nat : ℤ → ℕ → ℤ
| (int.of_nat b) e := int.of_nat (b ^ e)
| (int.neg_succ_of_nat b) 0 := 1
| (int.neg_succ_of_nat b) (k+1) := (int.neg_succ_of_nat b) * int.pow_nat (int.neg_succ_of_nat b) k
def int.pow_of_nat (b : ℕ) (e : ℕ) : int.pow_nat b e = int.of_nat (b ^ e) :=
eq.refl _ The reason it's not true by refl is clear when you look at the equations generated: #print prefix int.pow_nat
As you can see, it generated a spurious case split in the first case, so the theorem you want is actually true by As for why the elaborator thinks this theorem is okay and leaves it to the kernel to catch (and produce this snarky message), I'm not entirely sure. It doesn't seem like a big problem to me because the error is caught regardless. |
I do think either the error message should be changed, or the elaborator should be fixed; it seems poor form to have known tests that produce an error message that says "this is probably a bug" when it is known to not be a bug. (I do see why this theorem isn't proven by rfl, now; thanks for the explanation.) Perhaps this should get a "low priority" tag, or something? |
It is a bug in the elaborator, so I will leave this issue open in case anyone wants to investigate further, but it is low priority bug as you say. |
This error message does sometimes show up in places it shouldn't, for example if you forget to use the That said, the elaborator is changing in Lean 4 so it's likely the bug will disappear there. I wouldn't expect this to be fixed in Lean 3. It's rare (I've never seen it) and subtle (if you use |
Prerequisites
or feature requests.
Description
Expected behavior: either it passes, or I get
type mismatch
Actual behavior: I get an error message complaining about a possible bug
Reproduces how often: [What percentage of the time does it reproduce?] 100%
Versions
The text was updated successfully, but these errors were encountered: