feat: unfold ident,+

This commit is contained in:
Leonardo de Moura 2022-05-09 07:08:45 -07:00
parent 2680711f6a
commit fc03b2fc31
3 changed files with 11 additions and 7 deletions

View file

@ -260,10 +260,10 @@ syntax (name := dsimp) "dsimp " (config)? (discharger)? (&"only ")? ("[" (simpEr
This is a low-level tactic, it will expose how recursive definitions have been compiled by Lean. -/
syntax (name := delta) "delta " ident (location)? : tactic
/--
`unfold id` unfolds definition `id`. For non-recursive definitions, this tactic is identical to `delta`.
`unfold id,+` unfolds definition `id`. For non-recursive definitions, this tactic is identical to `delta`.
For recursive definitions, it hides the encoding tricks used by the Lean frontend to convince the
kernel that the definition terminates. -/
syntax (name := unfold) "unfold " ident (location)? : tactic
syntax (name := unfold) "unfold " ident,+ (location)? : tactic
-- Auxiliary macro for lifting have/suffices/let/...
-- It makes sure the "continuation" `?_` is the main goal after refining

View file

@ -21,11 +21,8 @@ def unfoldTarget (declName : Name) : TacticM Unit := do
-/
@[builtinTactic Lean.Parser.Tactic.unfold] def evalUnfold : Tactic := fun stx => do
let loc := expandOptLocation stx[2]
if stx[1].isIdent then
go stx[1] loc
else
for declNameId in stx[1].getSepArgs do
go declNameId loc
for declNameId in stx[1].getSepArgs do
go declNameId loc
where
go (declNameId : Syntax) (loc : Location) : TacticM Unit := do
let declName ← resolveGlobalConstNoOverload declNameId

View file

@ -0,0 +1,7 @@
def f (x : Nat) := x + 1
def g (x : Nat) := f x + f x
example : g x > 0 := by
unfold g, f
simp_arith