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" />
46 lines
1.2 KiB
Text
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:
|
|
[apply] 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:
|
|
[apply] 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?
|