lean4-htt/tests/lean/run/grind_try_exact.lean
Marc Huisinga 9d427fdfcf
feat: "try this" messages with support for interactivity (#10524)
This PR adds support for interactivity to the combined "try this"
messages that were introduced in #9966. In doing so, it moves the link
to apply a suggestion to a separate `[apply]` button in front of the
suggestion. Hints with diffs remain unchanged, as they did not
previously support interacting with terms in the diff, either.

<img width="379" height="256" alt="Suggestion with interactive message"
src="https://github.com/user-attachments/assets/7838ebf6-0613-46e7-bc88-468a05acbf51"
/>
2025-10-13 13:39:03 +00:00

50 lines
975 B
Text

module
public section -- TODO: `try?` fails if theorems are private
opaque P : Nat → Prop
opaque Q : Nat → Prop
theorem Pall : Q x → P x := sorry
/--
info: Try this:
[apply] exact Pall h
-/
#guard_msgs (info) in
example (h : Q x) (_ : x > 0) : P x := by
try?
/--
info: Try this:
[apply] · intros; expose_names; exact Pall h
-/
#guard_msgs (info) in
example: Q x → True → P x := by
try?
/--
info: Try this:
[apply] · intros; expose_names; exact Pall h_1
-/
#guard_msgs (info) in
example: True → Q x → True → P x := by
try?
theorem Qall {x y : Nat} : Q x := sorry
/--
error: Tactic `try?` failed: consider using `grind` manually, or `try? +missing` for partial proofs containing `sorry`
x : Nat
⊢ Q x
-/
#guard_msgs (error) in
example : Q x := by
try? -- should fail, we cannot elaborate `exact Qall`
/--
info: Try this:
[apply] · expose_names; exact Pall h
-/
#guard_msgs (info) in
example (_ : Q x) (_ : x > 0) : P x := by
try?