lean4-htt/tests/elab/apply_tac.lean
Garmelon 08eb78a5b2
chore: switch to new test/bench suite (#12590)
This PR sets up the new integrated test/bench suite. It then migrates
all benchmarks and some related tests to the new suite. There's also
some documentation and some linting.

For now, a lot of the old tests are left alone so this PR doesn't become
even larger than it already is. Eventually, all tests should be migrated
to the new suite though so there isn't a confusing mix of two systems.
2026-02-25 13:51:53 +00:00

70 lines
1.3 KiB
Text

import Lean
open Lean
open Lean.Elab
open Lean.Meta
open Lean.Elab.Tactic
/--
trace: a b c : Nat
h₁ : a = b
h₂ : b = c
⊢ a = b
-/
#guard_msgs in
example (a b c : Nat) (h₁ : a = b) (h₂ : b = c) : a = c := by
apply Eq.trans _ h₂ -- the metavars created during elaboration become new goals
trace_state
exact h₁
/--
trace: case h
a : Nat
⊢ ?w = a
case w
a : Nat
⊢ Nat
-/
#guard_msgs in
example (a : Nat) : ∃ x, x = a := by
apply Exists.intro -- the goal for the witness should occur "after" the goal for x = a
trace_state
rfl
elab "fapply " e:term : tactic =>
evalApplyLikeTactic (MVarId.apply (cfg := {newGoals := ApplyNewGoals.all})) e
elab "eapply " e:term : tactic =>
evalApplyLikeTactic (MVarId.apply (cfg := {newGoals := ApplyNewGoals.nonDependentOnly})) e
/--
trace: case h
a : Nat
⊢ ?w = a
-/
#guard_msgs in
example (a : Nat) : ∃ x, x = a := by
eapply Exists.intro -- only metavars with out forward dependencies are added as goals.
trace_state
rfl
/--
trace: case w
a : Nat
⊢ Nat
case h
a : Nat
⊢ ?w = a
---
trace: case h
a : Nat
⊢ a = a
-/
#guard_msgs in
example (a : Nat) : ∃ x, x = a := by
fapply Exists.intro -- all unassigned metavars are added as new goals using the order they were created.
trace_state
exact a
trace_state
rfl