Zulip Chat Archive
Stream: lean4
Topic: Lots of crashes after updating to `leanprover/lean4:v4.6.0`
Geoffrey Irving (Feb 06 2024 at 15:12):
I'm getting a lot of stack overflows after updating to v4.6.0. This is in slightly fragile code that has constants like 2^64 everywhere, and each crash is fixable by replacing simp
uses with rw
, so presumably what's happening is that simp
is now digging into the constants somehow in ways it didn't use to. It's slightly annoying to minimize as it takes down the whole Lean server each time:
Lean server printed an error: libc++abi: terminating due to uncaught exception of type lean::stack_space_exception: deep recursion was detected at 'replace' (potential solution: increase stack space in your system)
If this seems worth minimizing I can do that.
Matthew Ballard (Feb 06 2024 at 15:21):
Wild guess: some new simprocs
might be the culprit. I assume these can be disabled?
Jannis Limperg (Feb 06 2024 at 15:21):
set_option simprocs false
Geoffrey Irving (Feb 06 2024 at 15:22):
Here's a small example:
import Mathlib.Data.UInt
lemma UInt64.toNat_add (m n : UInt64) : (m + n).toNat = (m.toNat + n.toNat) % UInt64.size := by
simp only [UInt64.toNat, UInt64.add_def]
simp only [HAdd.hAdd, Add.add, Fin.add, Nat.add_eq]
Geoffrey Irving (Feb 06 2024 at 15:23):
That set_option doesn't seem to fix it.
Geoffrey Irving (Feb 06 2024 at 15:24):
Here's a version that doesn't crash, using different simp lemmas:
import Mathlib.Data.UInt
lemma UInt64.toNat_add (m n : UInt64) : (m + n).toNat = (m.toNat + n.toNat) % UInt64.size := by
simp only [UInt64.toNat, UInt64.add_def, Fin.add_def]
Patrick Massot (Feb 06 2024 at 15:54):
@Geoffrey Irving I suspect Leo will be very interested, but only if you build a Mathlib-free example.
Geoffrey Irving (Feb 06 2024 at 16:00):
Here's a crash with no imports:
theorem UInt64.add_def (a b : UInt64) : a + b = ⟨a.val + b.val⟩ := rfl
theorem UInt64.toNat_add (m n : UInt64) : (m + n).toNat = (m.toNat + n.toNat) % UInt64.size := by
simp only [UInt64.toNat, UInt64.add_def]
simp only [HAdd.hAdd, Add.add, Fin.add, Nat.add_eq]
Patrick Massot (Feb 06 2024 at 16:01):
Great, you can now open an issue in the lean4 repo.
Geoffrey Irving (Feb 06 2024 at 17:08):
https://github.com/leanprover/lean4/issues/3267
Last updated: May 02 2025 at 03:31 UTC