lean4-htt/tests/lean/run/qed_macro.lean
Kim Morrison 1c1c534a03
feat: add solve_by_elim to try? tactic pipeline (#11462)
This PR adds `solve_by_elim` as a fallback in the `try?` tactic's simple
tactics. When `rfl` and `assumption` both fail but `solve_by_elim`
succeeds (e.g., for goals requiring hypothesis chaining or
backtracking), `try?` will now suggest `solve_by_elim`.

The structure is `first | (attempt_all | rfl | assumption) |
solve_by_elim`, so `solve_by_elim` only runs when the faster tactics
fail.

This is a prerequisite for removing the "first pass" `solve_by_elim`
from `apply?`. Currently `apply?` calls `solve_by_elim` twice: once
before library search, and once after each lemma application. The first
pass can be removed once `try?` includes `solve_by_elim`.

🤖 Prepared with Claude Code

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-02 02:09:59 +00:00

57 lines
1.1 KiB
Text

/-
Test file for the ∎ (QED) macro which expands to `try?`
-/
import Lean.Elab.Tactic.Try
-- Basic tactic mode usage - should suggest tactics
/--
info: Try these:
[apply] rfl
[apply] simp
[apply] simp only [Nat.reduceAdd]
[apply] grind
[apply] grind only
[apply] simp_all
-/
#guard_msgs in
example : 1 + 1 = 2 := by
-- Term mode usage - should suggest terms with "by"
/--
info: Try these:
[apply] by rfl
[apply] by simp
[apply] by simp only [Nat.reduceAdd]
[apply] by grind
[apply] by grind only
[apply] by simp_all
-/
#guard_msgs in
example : 1 + 1 = 2 :=
-- With hypotheses in term mode
/--
info: Try these:
[apply] by solve_by_elim
[apply] by simp [*]
[apply] by simp only [h]
[apply] by grind
[apply] by grind only
[apply] by simp_all
-/
#guard_msgs in
example (a b : Nat) (h : a = b) : b = a :=
-- Check that error messages are appropriate when try? fails
/--
error: Tactic `try?` failed: consider using `grind` manually, or `try? +missing` for partial proofs containing `sorry`
⊢ False
-/
#guard_msgs in
example : False := by