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

40 lines
1.2 KiB
Text

import Std.Tactic.Do
open Std.Do
set_option mvcgen.warning false
/-!
The `mvcgen_trivial` tactic uses `trivial`, which uses `contradiction`.
For the example below, that triggers a recursion depth error.
We want to suggest to the user to use `-trivial` to avoid this.
-/
class MyAdd (Self : Type) (Rhs : Type)
where
add : (Self -> Rhs -> Except String Self)
instance : MyAdd Int32 Int32 := {
add x y := if BitVec.uaddOverflow x.toBitVec y.toBitVec then .error "error" else pure (x + y)
}
/--
error: Error while running try mvcgen_trivial on case vc2.isFalse.isTrue
t : Int32
h✝¹ : ¬t.toBitVec.uaddOverflow (Int32.toBitVec 1) = true
h✝ : (t + 1).toBitVec.uaddOverflow (Int32.toBitVec 3000) = true
⊢ ⏎
⊢ₛ wp⟦Except.error "error"⟧ (PostCond.noThrow fun r => ⌜True⌝)Message: ⏎
maximum recursion depth has been reached
use `set_option maxRecDepth <num>` to increase limit
use `set_option diagnostics true` to get diagnostic information
Try again with -trivial.
-/
#guard_msgs (error) in
example (t : Int32):
⦃ ⌜ True ⌝ ⦄
do
let t : Int32 ← (MyAdd.add t (1 : Int32))
MyAdd.add t (3000 : Int32)
⦃ ⇓ r => ⌜ True ⌝ ⦄ := by
mvcgen [MyAdd.add]