feat: add repeat tactic to conv mode

This commit is contained in:
Leonardo de Moura 2021-10-06 14:05:44 -07:00
parent 1f2e92ea04
commit 7f660af4c6
3 changed files with 15 additions and 0 deletions

View file

@ -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

View file

@ -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

View 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]