Zulip Chat Archive
Stream: mathlib4
Topic: ZMod maximum recursion depth
Jakob von Raumer (Jul 04 2023 at 11:10):
Has anybody come across this issue yet?
import Mathlib.Data.ZMod.Basic
example (x : ZMod 128) : ZMod (2^256) := x.cast -- gives maximum recursion depth error
There's a workaround by evaulating 2^256 first, but this is pretty annoying
Kevin Buzzard (Jul 04 2023 at 11:28):
It's not the cast:
import Mathlib.Data.ZMod.Basic
example (x : ℕ) : ZMod (2^256) := x -- max recursion
Jakob von Raumer (Jul 04 2023 at 11:34):
Yes, it's the modulus
Jakob von Raumer (Jul 04 2023 at 11:36):
But since the issue doesn't occur when replacing ZMod by Fin, I assume that to evaluate the cast (from Nat or from wherever) it needs to evaluate the modulus to determine whether it is 0, which in turn causes the issue
Matthew Ballard (Jul 04 2023 at 15:07):
def Bar : Nat → Type
| 0 => Unit
| _ => Unit
def foo : Bar (2^256) := .unit -- max recursion
Last updated: May 02 2025 at 03:31 UTC