lean4-htt/tests/elab/issue5061.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

33 lines
1 KiB
Text

opaque fin_max {n: Nat} (f: Fin n → Nat) : Nat
set_option maxRecDepth 30 in
-- NB: Important to not specify the implicit argument of fin_max here
def test (a: Array Nat) : Nat := @fin_max _ fun i =>
let h : i < a.size := by
-- this may apply once
with_reducible apply Fin.val_lt_of_le
fail_if_success with_reducible apply Fin.val_lt_of_le;
exact Nat.le_refl _
a[i]
set_option pp.mvars false
-- This used to cause
-- error: maximum recursion depth has been reached in #5061
/--
error: failed to prove index is valid, possible solutions:
- Use `have`-expressions to prove the index is valid
- Use `a[i]!` notation instead, runtime check is performed, and 'Panic' error message is produced if index is not valid
- Use `a[i]?` notation instead, result is an `Option` type
- Use `a[i]'h` notation instead, where `h` is a proof that index is valid
a : Array Nat
i : Fin ?_
⊢ ↑i < a.size
-/
#guard_msgs in
set_option maxRecDepth 40 in
def test2 (a: Array Nat) : Nat := @fin_max _ fun i =>
let h : i < a.size := by
get_elem_tactic
a[i]