lean4-htt/tests/lean/run/diagRec.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

24 lines
640 B
Text

@[semireducible]
def fib (n : Nat) :=
match n with
| 0 | 1 => 1
| x+2 => fib x + fib (x+1)
termination_by n
/--
info: 89
---
info: [diag] Diagnostics
[reduction] unfolded declarations (max: 407, num: 3):
[reduction] Nat.rec ↦ 407
[reduction] Or.rec ↦ 144
[reduction] Acc.rec ↦ 108
[reduction] unfolded reducible declarations (max: 352, num: 2):
[reduction] Nat.casesOn ↦ 352
[reduction] Or.casesOn ↦ 144
use `set_option diagnostics.threshold <num>` to control threshold for reporting counters
-/
#guard_msgs in
set_option diagnostics true in
set_option diagnostics.threshold 100 in
#reduce fib 10