@Kha It has a few advantages over `<or>` (`<|>`).
- It is not an infix operator.
- It takes tactic sequences instead of tactics as arguments
For example, we can write
```
first
| apply h1; assumption
| exact y; exact h3; assumption
```
or
```
first apply h1; assumption | exact y; exact h3; assumption
```
instead of
```
(apply h1; assumption) <|> (exact y; exact h3; assumption)
```
35 lines
652 B
Text
35 lines
652 B
Text
import Lean
|
|
|
|
|
|
|
|
open Lean.Elab.Term
|
|
open Lean.Elab.Command
|
|
|
|
elab "∃'" b:term "," P:term : term => do
|
|
let ex ← `(Exists (fun $b => $P));
|
|
elabTerm ex none
|
|
|
|
elab "#check2" b:term : command => do
|
|
let cmd ← `(#check $b #check $b);
|
|
elabCommand cmd
|
|
|
|
#check ∃' x, x > 0
|
|
|
|
#check ∃' (x : UInt32), x > 0
|
|
|
|
#check2 10
|
|
|
|
elab "try" t:tactic : tactic => do
|
|
let t' ← `(tactic| first $t | skip);
|
|
Lean.Elab.Tactic.evalTactic t'
|
|
|
|
theorem tst (x y z : Nat) : y = z → x = x → x = y → x = z :=
|
|
by {
|
|
intro h1; intro h2; intro h3;
|
|
apply @Eq.trans;
|
|
try exact h1; -- `exact h1` fails
|
|
traceState;
|
|
try exact h3;
|
|
traceState;
|
|
try exact h1;
|
|
}
|