fead: add evalInjection
This commit is contained in:
parent
cbf7a661df
commit
adce6df1a1
2 changed files with 33 additions and 0 deletions
|
|
@ -9,3 +9,4 @@ import Init.Lean.Elab.Tactic.Basic
|
|||
import Init.Lean.Elab.Tactic.ElabTerm
|
||||
import Init.Lean.Elab.Tactic.Induction
|
||||
import Init.Lean.Elab.Tactic.Generalize
|
||||
import Init.Lean.Elab.Tactic.Injection
|
||||
|
|
|
|||
32
src/Init/Lean/Elab/Tactic/Injection.lean
Normal file
32
src/Init/Lean/Elab/Tactic/Injection.lean
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/-
|
||||
Copyright (c) 2020 Microsoft Corporation. All rights reserved.
|
||||
Released under Apache 2.0 license as described in the file LICENSE.
|
||||
Authors: Leonardo de Moura
|
||||
-/
|
||||
prelude
|
||||
import Init.Lean.Meta.Tactic.Injection
|
||||
import Init.Lean.Elab.Tactic.ElabTerm
|
||||
|
||||
namespace Lean
|
||||
namespace Elab
|
||||
namespace Tactic
|
||||
|
||||
-- optional (" with " >> many1 ident')
|
||||
private def getInjectionNewIds (stx : Syntax) : List Name :=
|
||||
if stx.isNone then []
|
||||
else (stx.getArg 1).getArgs.toList.map Syntax.getId
|
||||
|
||||
@[builtinTactic «injection»] def evalInjection : Tactic :=
|
||||
fun stx => do
|
||||
-- parser! nonReservedSymbol "injection " >> termParser >> withIds
|
||||
fvarId ← elabAsFVar (stx.getArg 1);
|
||||
let ids := getInjectionNewIds (stx.getArg 2);
|
||||
liftMetaTactic stx $ fun mvarId => do
|
||||
r ← Meta.injection mvarId fvarId ids (!ids.isEmpty);
|
||||
match r with
|
||||
| Meta.InjectionResult.solved => pure []
|
||||
| Meta.InjectionResult.subgoal mvarId _ _ => pure [mvarId]
|
||||
|
||||
end Tactic
|
||||
end Elab
|
||||
end Lean
|
||||
Loading…
Add table
Reference in a new issue