Files
lean4/tests/elab/4644.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

52 lines
1.8 KiB
Lean4
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
def sorted_to_var [x: LE α] [DecidableRel x.le] (a: Array α) (i: Nat) (h : i + 1 < a.size) : Bool :=
match i with
| 0 => true
| i+1 =>
have : i + 1 < a.size := Nat.lt_of_succ_lt h
a[i] a[i+1] && sorted_to_var a i this
termination_by structural i
attribute [irreducible] sorted_to_var
def check_sorted [x: LE α] [DecidableRel x.le] (a: Array α): Bool :=
if h : a.size 1
then true
else sorted_to_var a (a.size - 2) (by omega)
/--
error: Tactic `rfl` failed: The left-hand side
check_sorted #[0, 3, 3, 5, 8, 10, 10, 10]
is not definitionally equal to the right-hand side
true
⊢ check_sorted #[0, 3, 3, 5, 8, 10, 10, 10] = true
-/
#guard_msgs in
example: check_sorted #[0, 3, 3, 5, 8, 10, 10, 10] = true := by
rfl -- fails because `rfl` uses `.default` transparency, and `sorted_from_var` is marked as irreducible
/--
error: Tactic `decide` failed for proposition
check_sorted #[0, 3, 3, 5, 8, 10, 10, 10] = true
because its `Decidable` instance
instDecidableEqBool (check_sorted #[0, 3, 3, 5, 8, 10, 10, 10]) true
did not reduce to `isTrue` or `isFalse`.
After unfolding the instances `instDecidableEqBool`, `Bool.decEq`, and `Nat.decLe`, reduction got stuck at the `Decidable` instance
match check_sorted #[0, 3, 3, 5, 8, 10, 10, 10], true with
| false, false => isTrue ⋯
| false, true => isFalse ⋯
| true, false => isFalse ⋯
| true, true => isTrue ⋯
-/
#guard_msgs in
example: check_sorted #[0, 3, 3, 5, 8, 10, 10, 10] := by
decide -- fails because `decide` uses `.default` transparency, and `sorted_from_var` is marked as irreducible
unseal sorted_to_var in
example: check_sorted #[0, 3, 3, 5, 8, 10, 10, 10] := by
decide -- works
example: check_sorted #[0, 3, 3, 5, 8, 10, 10, 10] := by
with_unfolding_all decide -- should work