lean4-htt/tests/lean/run/kernel_maxheartbeats.lean
Joachim Breitner 41a2e9af19
feat: well-founded recursion: opaque well-foundedness proofs (#5182)
This PR makes functions defined by well-founded recursion use an
`opaque` well-founded proof by default. This reliably prevents kernel
reduction of such definitions and proofs, which tends to be
prohibitively slow (fixes #2171), and which regularly causes
hard-to-debug kernel type-checking failures. This changes renders
`unseal` ineffective for such definitions. To avoid the opaque proof,
annotate the function definition with `@[semireducible]`.
2025-03-19 09:21:04 +00:00

21 lines
478 B
Text

import Lean
@[semireducible]
def ack : Nat → Nat → Nat
| 0, y => y+1
| x+1, 0 => ack x 1
| x+1, y+1 => ack x (ack (x+1) y)
set_option maxHeartbeats 500
open Lean Meta
/-- error: (kernel) deterministic timeout -/
#guard_msgs in
run_meta do
let type ← mkEq (← mkAppM ``ack #[mkNatLit 4, mkNatLit 4]) (mkNatLit 100000)
let value ← mkEqRefl (mkNatLit 100000)
addDecl <| .thmDecl {
name := `ack_4_4
levelParams := []
type, value
}