99public import Lean.Meta.Tactic.LibrarySearch
1010public import Lean.Meta.Tactic.TryThis
1111public import Lean.Elab.Tactic.ElabTerm
12+ public import Lean.Elab.Tactic.Config
1213
1314public section
1415
@@ -17,22 +18,27 @@ namespace Lean.Elab.LibrarySearch
1718open Lean Meta LibrarySearch
1819open Elab Tactic Term TryThis
1920
21+ declare_config_elab elabLibrarySearchConfig Parser.Tactic.LibrarySearchConfig
22+
2023/--
2124Implementation of the `exact?` tactic.
2225
2326* `ref` contains the input syntax and is used for locations in error reporting.
27+ * `config` contains configuration options (e.g., `grind` for using grind as a discharger).
2428* `required` contains an optional list of terms that should be used in closing the goal.
2529* `requireClose` indicates if the goal must be closed.
2630 It is `true` for `exact?` and `false` for `apply?`.
2731 -/
28- def exact? (ref : Syntax) (required : Option (Array (TSyntax `term))) (requireClose : Bool) :
32+ def exact? (ref : Syntax) (config : Parser.Tactic.LibrarySearchConfig)
33+ (required : Option (Array (TSyntax `term))) (requireClose : Bool) :
2934 TacticM Unit := do
3035 let mvar ← getMainGoal
3136 let initialState ← saveState
3237 let (_, goal) ← (← getMainGoal).intros
3338 goal.withContext do
3439 let required := (← (required.getD #[]).mapM getFVarId).toList.map .fvar
35- let tactic := fun goals => solveByElim required (exfalso := false ) goals (maxDepth := 6 )
40+ let tactic := fun goals =>
41+ solveByElim required (exfalso := false ) goals (maxDepth := 6 ) (grind := config.grind)
3642 let allowFailure := fun g => do
3743 let g ← g.withContext (instantiateMVars (.mvar g))
3844 return required.all fun e => e.occurs g
@@ -55,16 +61,18 @@ def exact? (ref : Syntax) (required : Option (Array (TSyntax `term))) (requireCl
5561
5662@[builtin_tactic Lean.Parser.Tactic.exact?]
5763def evalExact : Tactic := fun stx => do
58- let `(tactic| exact? $[using $[$required],*]?) := stx
64+ let `(tactic| exact? $cfg:optConfig $ [using $[$required],*]?) := stx
5965 | throwUnsupportedSyntax
60- exact? (← getRef) required true
66+ let config ← elabLibrarySearchConfig cfg
67+ exact? (← getRef) config required true
6168
6269
6370@[builtin_tactic Lean.Parser.Tactic.apply?]
6471def evalApply : Tactic := fun stx => do
65- let `(tactic| apply? $[using $[$required],*]?) := stx
72+ let `(tactic| apply? $cfg:optConfig $ [using $[$required],*]?) := stx
6673 | throwUnsupportedSyntax
67- exact? (← getRef) required false
74+ let config ← elabLibrarySearchConfig cfg
75+ exact? (← getRef) config required false
6876
6977@[builtin_term_elab Lean.Parser.Syntax.exact?]
7078def elabExact?Term : TermElab := fun stx expectedType? => do
0 commit comments