Created
September 6, 2024 09:36
-
-
Save nomeata/e368723d9d236452f97ef7e66e652532 to your computer and use it in GitHub Desktop.
Lean4’s Nat.succ in kernel is stricter than expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Lean | |
import Mathlib | |
elab "#kernel_reduce" t:term : command => Lean.Elab.Command.runTermElabM fun _ => do | |
let e ← Lean.Elab.Term.elabTermAndSynthesize t none | |
let e' ← Lean.ofExceptKernelException <| Lean.Kernel.whnf (← Lean.getEnv) (← Lean.getLCtx) e | |
Lean.logInfo m!"{e'}" | |
def slow : Bool := Nat.sqrt (1000 * 1000) = 1000 | |
/-- error: (kernel) deep recursion detected -/ | |
#guard_msgs in | |
#kernel_reduce slow | |
/-- error: (kernel) deep recursion detected -/ | |
#guard_msgs in | |
#kernel_reduce Nat.succ (if slow then 1 else 2) | |
/-- info: [if slow = true then 1 else 2] -/ | |
#guard_msgs in | |
#kernel_reduce List.cons (if slow then 1 else 2) [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment