-
Notifications
You must be signed in to change notification settings - Fork 428
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
simp_arith: unwanted reduction of atoms due to overloaded vs. nonoverloaded operations #6152
Comments
I investigated this closer and noticed that it matters whether I use the overloaded or the non-overloaded operations in the type hint. This runs into the kernel recursion again:
And indeed that’s the issue: We cannot leave it to the kernel to prove
(Curious that these pass the elaborator’s defeq check; different heuristics, it seems!) This raises two questions: What exactly is happening with And indeed the latter is true:
so the bug isn’t fixed properly. This is what’s happening in simp_arith:
So my fix, by introducing the abstraction and the type hint, had two effects:
This worked in the cases where the goal uses the overloaded functions, matching the type hint. But we still have a bug if the non-overloaded functions appear in the goal. A possible fix could be extend the Another possible fix could be to restrict Of course it would be nice if the kernel would simply do the right thing, and not reduce |
Ok, the fix doesn’t actually work (see branch Even if the goal, the denotation function and the type hint all use the plain Maybe the problem isn’t fixable outside the kernel, and this
Tricky. Here is a test case that shows that the too eager evaluation here: -- A function that reduced badly, as a canary for kernel reduction
def bad (n : Nat) : Nat :=
if h : n = 0 then 0 else bad (n / 2)
termination_by n
def Nat_mul := @Nat.mul
/-- error: (kernel) deep recursion detected -/
#guard_msgs in
example : Nat_mul 2 (bad 42000) = Nat.mul 2 (bad 42000) := by rfl
/-- error: (kernel) deep recursion detected -/
#guard_msgs in
example : id (Nat.mul 2 (bad 42000)) = Nat.mul 2 (bad 42000) := by rfl This makes it hard to write any kind of denotation function or even a type hint that would relate to an expression headed by |
In #5384 we found that this blows up with kernel deep recursion:
This was fixed in #5708, but abstracting out atoms in the actual proof by reflection.
It turns out that the the fix isn’t complete, as
and
still blows up.
Versions
Lean 4.15.0-nightly-2024-11-20
The text was updated successfully, but these errors were encountered: