fix: shake: only record non-builtin simprocs (#11344)

This commit is contained in:
Sebastian Ullrich 2025-11-29 16:58:29 +01:00 committed by GitHub
parent 075f1d66eb
commit 4eba5ea96d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 8 deletions

View file

@ -12,6 +12,7 @@ public import Lean.Meta.Tactic.Simp.Diagnostics
public import Lean.Meta.Match.Value
public import Lean.Util.CollectLooseBVars
import Lean.PrettyPrinter
import Lean.ExtraModUses
public section
@ -1069,15 +1070,29 @@ def simpImpl (e : Expr) : SimpM Result := withIncRecDepth do
else
x
/--
For `rfl` theorems and simprocs, there might not be an explicit reference in the proof term, so
we record (all non-builtin) usages explicitly.
-/
private def recordSimpUses (s : State) : MetaM Unit := do
for (thm, _) in s.usedTheorems.map do
if let .decl declName .. := thm then
if !(← isBuiltinSimproc declName) then
recordExtraModUseFromDecl (isMeta := false) declName
def mainCore (e : Expr) (ctx : Context) (s : State := {}) (methods : Methods := {}) : MetaM (Result × State) := do
SimpM.run ctx s methods <| withCatchingRuntimeEx <| simp e
let (r, s) ← SimpM.run ctx s methods <| withCatchingRuntimeEx <| simp e
recordSimpUses s
return (r, s)
def main (e : Expr) (ctx : Context) (stats : Stats := {}) (methods : Methods := {}) : MetaM (Result × Stats) := do
let (r, s) ← mainCore e ctx { stats with } methods
return (r, { s with })
def dsimpMainCore (e : Expr) (ctx : Context) (s : State := {}) (methods : Methods := {}) : MetaM (Expr × State) := do
SimpM.run ctx s methods <| withCatchingRuntimeEx <| dsimp e
let (r, s) ← SimpM.run ctx s methods <| withCatchingRuntimeEx <| dsimp e
recordSimpUses s
return (r, s)
def dsimpMain (e : Expr) (ctx : Context) (stats : Stats := {}) (methods : Methods := {}) : MetaM (Expr × Stats) := do
let (r, s) ← dsimpMainCore e ctx { stats with } methods

View file

@ -12,7 +12,6 @@ public import Lean.Meta.Eqns
public import Lean.Meta.Tactic.Simp.SimpTheorems
public import Lean.Meta.Tactic.Simp.SimpCongrTheorems
import Lean.Meta.Tactic.Replace
import Lean.ExtraModUses
public section
@ -881,11 +880,6 @@ def SimpM.run (ctx : Context) (s : State := {}) (methods : Methods := {}) (k : S
trace[Meta.Tactic.simp.numSteps] "{s.numSteps}"
let stats ← updateUsedSimpsWithZetaDelta ctx { s with }
let s := { s with diag := stats.diag, usedTheorems := stats.usedTheorems }
for (thm, _) in s.usedTheorems.map do
if let .decl declName .. := thm then
-- for `rfl` theorems and simprocs, there might not be an explicit reference in the proof
-- term
recordExtraModUseFromDecl (isMeta := false) declName
return (r, s)
end Simp