lean4-htt/tests/lean/run/3922.lean
Marc Huisinga f180eee7bf
feat: use widget message for "try this" (#9966)
This PR adjusts the "try this" widget to be rendered as a widget message
under 'Messages', not a separate widget under a 'Suggestions' section.
The main benefit of this is that the message of the widget is not
duplicated between 'Messages' and 'Suggestions'.

Since widget message suggestions were already implemented by @jrr6 for
the new hint infrastructure, this PR replaces the old "try this"
implementation with the new hint infrastructure. In doing so, the
`style?` field of suggestions is deprecated, since the hint
infrastructure highlights hints using diff colors, and `style?` also
never saw much use downstream. Additionally, since the message and the
suggestion are now the same component, the `messageData?` field of
suggestions is deprecated as well. Notably, the "Try this:" message
string now also contains a newline and indentation to separate the
suggestion from the rest of the message more clearly and the `postInfo?`
field of the suggestion is now part of the message.

Finally, this PR changes the diff colors used by the hint infrastructure
to be more color-blindness-friendly (insertions are now blue, not green,
and text that remains unchanged is now using the editor foreground color
instead of blue).

### Breaking changes
Tests that use `#guard_msgs` to test the "Try this:" message may need to
be adjusted for the new formatting of the message.
2025-08-26 12:15:32 +00:00

46 lines
1.2 KiB
Text

/-!
# Issue 3922
The `apply?` tactic would apply `symm` to every hypothesis in the local context,
leading to these new hypotheses being included in the term even if they weren't used.
They also created unelaboratable terms such as `?_ (id (r.symm h₂))`.
-/
set_option linter.unusedVariables false
-- set up a binary relation
axiom r : Nat → Nat → Prop
-- that is symmetric
axiom r.symm {a b : Nat} : r a b → r b a
-- and has some other property
axiom r.trans {a b c : Nat} : r a b → r b c → r a c
/--
info: Try this:
refine r.symm ?_
-- Remaining subgoals:
-- ⊢ r a c
---
info: found a partial proof, but the corresponding tactic failed:
(expose_names; refine r.trans ?_ ?_)
It may be possible to correct this proof by adding type annotations, explicitly specifying implicit arguments, or eliminating unnecessary function abstractions.
---
warning: declaration uses 'sorry'
-/
#guard_msgs (ordering := sorted) in
example (a b c : Nat) (h₁ : r b a) (h₂ : r b c) : r c a := by
apply?
-- now attach the `symm` attribute to `r.symm`
attribute [symm] r.symm
/--
info: Try this:
exact r.trans (id (r.symm h₂)) h₁
-/
#guard_msgs in
example (a b c : Nat) (h₁ : r b a) (h₂ : r b c) : r c a := by
apply?