Skip to content

Commit

Permalink
fix: allow builtin simprocs to be deleted even when we have not impor…
Browse files Browse the repository at this point in the history
…ted the file defining them
  • Loading branch information
leodemoura committed Feb 26, 2024
1 parent e26a962 commit bf8f40a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Lean/Elab/Declaration.lean
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,21 @@ def elabMutual : CommandElab := fun stx => do
let attrs ← elabAttrs attrInsts
let idents := stx[4].getArgs
for ident in idents do withRef ident <| liftTermElabM do
let declName ← resolveGlobalConstNoOverloadWithInfo ident
/-
HACK to allow `attribute` command to disable builtin simprocs.
TODO: find a better solution. Example: have some "fake" declaration
for builtin simprocs.
-/
let declNames ←
try
resolveGlobalConst ident
catch _ =>
let name := ident.getId.eraseMacroScopes
if (← Simp.isBuiltinSimproc name) then
pure [name]
else
throwUnknownConstant name
let declName ← ensureNonAmbiguous ident declNames
Term.applyAttributes declName attrs
for attrName in toErase do
Attribute.erase declName attrName
Expand Down
12 changes: 12 additions & 0 deletions tests/lean/run/simproc_builtin_erase.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
example (h : 12 = x) : 10 + 2 = x := by
simp
guard_target =ₛ 12 = x
assumption

attribute [-simp] Nat.reduceAdd

example (h : 12 = x) : 10 + 2 = x := by
fail_if_success simp
simp [Nat.reduceAdd]
guard_target =ₛ 12 = x
assumption

0 comments on commit bf8f40a

Please sign in to comment.