feat: add repeat tactic to conv mode
This commit is contained in:
parent
1f2e92ea04
commit
7f660af4c6
3 changed files with 15 additions and 0 deletions
|
|
@ -62,4 +62,11 @@ macro "done" : conv => `(tactic' => done)
|
|||
macro "trace_state" : conv => `(tactic' => trace_state)
|
||||
macro "apply " e:term : conv => `(tactic => apply $e)
|
||||
|
||||
/-- `first | conv | ...` runs each `conv` until one succeeds, or else fails. -/
|
||||
syntax (name := first) "first " withPosition((group(colGe "|" convSeq))+) : conv
|
||||
|
||||
syntax "repeat " convSeq : conv
|
||||
macro_rules
|
||||
| `(conv| repeat $seq) => `(conv| first | ($seq); repeat $seq | skip)
|
||||
|
||||
end Lean.Parser.Tactic.Conv
|
||||
|
|
|
|||
|
|
@ -147,4 +147,7 @@ private def convLocalDecl (conv : Syntax) (hUserName : Name) : TacticM Unit := w
|
|||
convTarget code
|
||||
| _ => throwUnsupportedSyntax
|
||||
|
||||
@[builtinTactic Lean.Parser.Tactic.Conv.first] partial def evalFirst : Tactic :=
|
||||
Tactic.evalFirst
|
||||
|
||||
end Lean.Elab.Tactic.Conv
|
||||
|
|
|
|||
5
tests/lean/run/repeatConv.lean
Normal file
5
tests/lean/run/repeatConv.lean
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
example : (fun x y => (0 + x) + (0 + y)) = Nat.add := by
|
||||
conv =>
|
||||
lhs
|
||||
intro x y
|
||||
repeat rw [Nat.zero_add]
|
||||
Loading…
Add table
Reference in a new issue