lean4-htt/tests/elab/ack.lean
Garmelon 08eb78a5b2
chore: switch to new test/bench suite (#12590)
This PR sets up the new integrated test/bench suite. It then migrates
all benchmarks and some related tests to the new suite. There's also
some documentation and some linting.

For now, a lot of the old tests are left alone so this PR doesn't become
even larger than it already is. Eventually, all tests should be migrated
to the new suite though so there isn't a confusing mix of two systems.
2026-02-25 13:51:53 +00:00

106 lines
3.2 KiB
Text

/-! This file tests kernel diagnostics reporting, triggered using the expensive `ack` function. -/
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)
termination_by a b => (a, b)
section async_true
/--
trace: [simp] Diagnostics
[simp] used theorems (max: 57, num: 1):
[simp] ack.eq_3 ↦ 57
[simp] tried theorems (max: 57, num: 1):
[simp] ack.eq_3 ↦ 57, succeeded: 57
use `set_option diagnostics.threshold <num>` to control threshold for reporting counters
---
trace: [diag] Diagnostics
[kernel] unfolded declarations (max: 176, num: 3):
[kernel] OfNat.ofNat ↦ 176
[kernel] Add.add ↦ 60
[kernel] HAdd.hAdd ↦ 60
use `set_option diagnostics.threshold <num>` to control threshold for reporting counters
-/
#guard_msgs in
set_option diagnostics.threshold 50 in
set_option diagnostics true in
theorem ex : ack 3 2 = 29 :=
by simp [ack]
end async_true
section async_false
set_option Elab.async false
/--
trace: [simp] Diagnostics
[simp] used theorems (max: 57, num: 1):
[simp] ack.eq_3 ↦ 57
[simp] tried theorems (max: 57, num: 1):
[simp] ack.eq_3 ↦ 57, succeeded: 57
use `set_option diagnostics.threshold <num>` to control threshold for reporting counters
---
trace: [diag] Diagnostics
[kernel] unfolded declarations (max: 174, num: 3):
[kernel] OfNat.ofNat ↦ 174
[kernel] Add.add ↦ 58
[kernel] HAdd.hAdd ↦ 58
use `set_option diagnostics.threshold <num>` to control threshold for reporting counters
-/
#guard_msgs in
set_option diagnostics.threshold 50 in
set_option diagnostics true in
theorem ex2 : ack 3 2 = 29 :=
by simp [ack]
end async_false
-- Check that kernel diagnostics are also reported in examples
/--
trace: [simp] Diagnostics
[simp] used theorems (max: 57, num: 1):
[simp] ack.eq_3 ↦ 57
[simp] tried theorems (max: 57, num: 1):
[simp] ack.eq_3 ↦ 57, succeeded: 57
use `set_option diagnostics.threshold <num>` to control threshold for reporting counters
---
trace: [diag] Diagnostics
[kernel] unfolded declarations (max: 174, num: 3):
[kernel] OfNat.ofNat ↦ 174
[kernel] Add.add ↦ 58
[kernel] HAdd.hAdd ↦ 58
use `set_option diagnostics.threshold <num>` to control threshold for reporting counters
-/
#guard_msgs in
set_option diagnostics.threshold 50 in
set_option diagnostics true in
example : ack 3 2 = 29 :=
by simp [ack]
-- Also in nested lemma
/--
trace: [simp] Diagnostics
[simp] used theorems (max: 57, num: 1):
[simp] ack.eq_3 ↦ 57
[simp] tried theorems (max: 57, num: 1):
[simp] ack.eq_3 ↦ 57, succeeded: 57
use `set_option diagnostics.threshold <num>` to control threshold for reporting counters
---
trace: [diag] Diagnostics
[def_eq] heuristic for solving `f a =?= f b` (max: 60, num: 1):
[def_eq] ack ↦ 60
[kernel] unfolded declarations (max: 174, num: 3):
[kernel] OfNat.ofNat ↦ 174
[kernel] Add.add ↦ 58
[kernel] HAdd.hAdd ↦ 58
use `set_option diagnostics.threshold <num>` to control threshold for reporting counters
-/
#guard_msgs in
set_option diagnostics.threshold 50 in
set_option diagnostics true in
theorem ex3 : ack 3 2 = 29 :=
by as_aux_lemma => simp [ack]