lean4-htt/tests/lean/run/grind_erase_attr.lean
Joachim Breitner 0e49576fe4
feat: guard_msgs to treat trace messages separate (#8267)
This PR makes `#guard_msgs` to treat `trace` messages separate from
`info`, `warning` and `error`. It also introduce the ability to say
`#guard_msgs (pass info`, like `(drop info)` so far, and also adds
`(check info)` as the explicit form of `(info)`, for completeness.

Fixes #8266
2025-05-09 05:44:34 +00:00

76 lines
1.3 KiB
Text

opaque f : Nat → Nat
@[grind] theorem fthm : f (f x) = f x := sorry
theorem fthm' : f (f x) = x := sorry
/--
error: `fthm'` is not marked with the `[grind]` attribute
-/
#guard_msgs in
attribute [-grind] fthm'
set_option trace.grind.assert true
/--
trace: [grind.assert] ¬f (f (f a)) = f a
[grind.assert] f (f a) = f a
-/
#guard_msgs (trace) in
example : f (f (f a)) = f a := by
grind
attribute [-grind] fthm
/--
error: unsolved goals
a : Nat
⊢ f (f (f a)) = f a
---
trace: [grind.assert] ¬f (f (f a)) = f a
-/
#guard_msgs (trace, error) in
example : f (f (f a)) = f a := by
fail_if_success grind
/--
error: `fthm` is not marked with the `[grind]` attribute
-/
#guard_msgs in
attribute [-grind] fthm
attribute [grind] fthm
example : f (f (f a)) = f a := by
grind
def g (x : Nat) :=
match x with
| 0 => 1
| x+1 => 2 * g x
attribute [grind] g
example : g a = b → a = 0 → b = 1 := by
grind
attribute [-grind] g
/--
error: unsolved goals
a b : Nat
⊢ g a = b → a = 0 → b = 1
---
trace: [grind.assert] g a = b
[grind.assert] a = 0
[grind.assert] ¬b = 1
-/
#guard_msgs (trace, error) in
example : g a = b → a = 0 → b = 1 := by
fail_if_success grind
/--
error: `g` is not marked with the `[grind]` attribute
-/
#guard_msgs in
attribute [-grind] g