@@ -188,7 +188,13 @@ def elabGrindSuggestions
188188 match attr with
189189 | .ematch kind =>
190190 try
191+ let oldSize := params.extraFacts.size
191192 params ← addEMatchTheorem params (mkIdent p.name) p.name kind false (warn := false )
193+ -- If the theorem went to extraFacts (ground theorem), synthesize syntax for it.
194+ -- Ground theorems bypass E-matching, so we need to track them separately for suggestions.
195+ if params.extraFacts.size > oldSize then
196+ let stx ← `(Parser.Tactic.grindParam| $(mkIdent p.name):ident)
197+ params := { params with extraFactsSyntax := params.extraFactsSyntax.push stx.raw }
192198 catch _ => pure () -- Don't worry if library suggestions gave bad theorems.
193199 | _ =>
194200 -- We could actually support arbitrary grind modifiers,
@@ -335,19 +341,12 @@ def evalGrindTraceCore (stx : Syntax) (trace := true) (verbose := true) (useSorr
335341 let config := { config with clean := false , trace, verbose, useSorry }
336342 let only := only.isSome
337343 let paramStxs := if let some params := params? then params.getElems else #[]
338- -- Extract term parameters (non-ident params) to include in the suggestion.
339- -- These are not tracked via E-matching, so we conservatively include them all.
340- -- Ident params resolve to global declarations and are tracked via E-matching.
341- -- Non-ident terms (like `show P by tac`) need to be preserved explicitly.
342- let termParamStxs : Array Grind.TParam := paramStxs.filter fun p =>
343- match p with
344- | `(Parser.Tactic.grindParam| $[$_:grindMod]? $_:ident) => false
345- | `(Parser.Tactic.grindParam| ! $[$_:grindMod]? $_:ident) => false
346- | `(Parser.Tactic.grindParam| - $_:ident) => false
347- | `(Parser.Tactic.grindParam| #$_:hexnum) => false
348- | _ => true
349344 let mvarId ← getMainGoal
350345 let params ← mkGrindParams config only paramStxs mvarId
346+ -- Extract syntax of params that went to `extraFacts` (ground theorems and term arguments).
347+ -- These need to be included in `grind only` suggestions since they're not tracked via E-matching.
348+ let termParamStxs : Array Grind.TParam := params.extraFactsSyntax.filterMap fun s =>
349+ if s.isOfKind ``Parser.Tactic.grindParam then some ⟨s⟩ else none
351350 Grind.withProtectedMCtx config.abstractProof mvarId fun mvarId' => do
352351 let (tacs, _) ← Grind.GrindTacticM.runAtGoal mvarId' params do
353352 let finish ← Grind.Action.mkFinish
0 commit comments