Skip to content

Commit 890c4e9

Browse files
committed
now do the same in dsimp as well
1 parent 9eb4dbe commit 890c4e9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/Lean/Meta/Tactic/Simp/Main.lean

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -439,12 +439,13 @@ private def doNotVisitProofs : DSimproc := fun e => do
439439
else
440440
return .continue e
441441

442-
/-- Helper `dsimproc` for `doNotVisitOfNat` and `doNotVisitOfScientific` -/
443-
private def doNotVisit (pred : Expr → Bool) (declName : Name) : DSimproc := fun e => do
442+
/-- Helper `dsimproc` for `visitOfNat` and `visitOfScientific` -/
443+
@[specialize] private def visitNum (pred : Expr → Bool) (declName : Name) : DSimproc := fun e => do
444444
if pred e then
445445
if (← readThe Simp.Context).isDeclToUnfold declName then
446446
return .continue e
447447
else
448+
let e ← withFreshDSimpCache <| withInNumLit <| e.withApp fun f args => return mkAppN f (← args.mapM dsimp)
448449
-- Users may have added a `[simp]` rfl theorem for the literal
449450
match (← (← getMethods).dpost e) with
450451
| .continue none => return .done e
@@ -457,25 +458,25 @@ Auxiliary `dsimproc` for not visiting `OfNat.ofNat` application subterms.
457458
This is the `dsimp` equivalent of the approach used at `visitApp`.
458459
Recall that we fold orphan raw Nat literals.
459460
-/
460-
private def doNotVisitOfNat : DSimproc := doNotVisit isOfNatNatLit ``OfNat.ofNat
461+
private def visitOfNat : DSimproc := visitNum isOfNatNatLit ``OfNat.ofNat
461462

462463
/--
463464
Auxiliary `dsimproc` for not visiting `OfScientific.ofScientific` application subterms.
464465
-/
465-
private def doNotVisitOfScientific : DSimproc := doNotVisit isOfScientificLit ``OfScientific.ofScientific
466+
private def visitOfScientific : DSimproc := visitNum isOfScientificLit ``OfScientific.ofScientific
466467

467468
/--
468469
Auxiliary `dsimproc` for not visiting `Char` literal subterms.
469470
-/
470-
private def doNotVisitCharLit : DSimproc := doNotVisit isCharLit ``Char.ofNat
471+
private def visitCharLit : DSimproc := visitNum isCharLit ``Char.ofNat
471472

472473
@[export lean_dsimp]
473474
private partial def dsimpImpl (e : Expr) : SimpM Expr := do
474475
let cfg ← getConfig
475476
unless cfg.dsimp do
476477
return e
477478
let m ← getMethods
478-
let pre := m.dpre >> doNotVisitOfNat >> doNotVisitOfScientific >> doNotVisitCharLit >> doNotVisitProofs
479+
let pre := m.dpre >> visitOfNat >> visitOfScientific >> visitCharLit >> doNotVisitProofs
479480
let post := m.dpost >> dsimpReduce
480481
withInDSimpWithCache fun cache => do
481482
transformWithCache e cache (usedLetOnly := cfg.zeta || cfg.zetaUnused) (pre := pre) (post := post)

0 commit comments

Comments
 (0)