Skip to content

Commit 6a1be36

Browse files
committed
chore: deprecate memoFix and replaceRec (leanprover-community#34384)
This deprecation was requested by Floris van Doorn in leanprover-community#33236
1 parent 534cf0b commit 6a1be36

5 files changed

Lines changed: 15 additions & 50 deletions

File tree

Mathlib/Lean/Expr.lean

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ Authors: Mario Carneiro, Simon Hudon, Kim Morrison, Keeley Hoek, Robert Y. Lewis
66
module
77

88
public import Mathlib.Lean.Expr.Basic
9-
public import Mathlib.Lean.Expr.ReplaceRec
9+
public import Mathlib.Tactic.Linter.DeprecatedModule
10+
11+
deprecated_module (since := "2026-01-27")

Mathlib/Lean/Expr/ReplaceRec.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module
88

99
public import Lean.Expr
1010
public import Mathlib.Util.MemoFix
11+
public import Mathlib.Tactic.Linter.DeprecatedModule
1112

1213
/-!
1314
# ReplaceRec
@@ -16,6 +17,10 @@ We define a more flexible version of `Expr.replace` where we can use recursive c
1617
replacing a subexpression. We completely mimic the implementation of `Expr.replace`.
1718
-/
1819

20+
deprecated_module (since := "2026-01-26")
21+
22+
set_option linter.deprecated false
23+
1924
@[expose] public section
2025

2126
namespace Lean.Expr
@@ -29,6 +34,7 @@ If you wish to recursively replace things in the implementation of `f?`, you can
2934
3035
The function is also memoised, which means that if the
3136
same expression (by reference) is encountered the cached replacement is used. -/
37+
@[deprecated "use `MonadCacheT` and `checkCache`" (since := "2026-01-24")]
3238
def replaceRec (f? : (Expr → Expr) → Expr → Option Expr) : Expr → Expr :=
3339
memoFix fun r e ↦
3440
match f? r e with

Mathlib/Tactic/Linter/DirectoryDependency.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ public def directoryDependencyCheck (mainModule : Name) : CommandElabM (Array Me
647647
-- `ImportGraph`, `ProofWidgets` or `LeanSearchClient` (as these are imported in Tactic.Common).
648648
-- We also allow transitive imports of Mathlib.Init, as well as Mathlib.Init itself.
649649
let initImports := (← findImports ("Mathlib" / "Init.lean")).append
650-
#[`Mathlib.Init, `Mathlib.Tactic.DeclarationNames]
650+
#[`Mathlib.Init, `Mathlib.Tactic.DeclarationNames, `Mathlib.Tactic.Linter.DeprecatedModule]
651651
let exclude := [
652652
`Init, `Std, `Lean,
653653
`Aesop, `Qq, `Plausible, `ImportGraph, `ProofWidgets, `LeanSearchClient

Mathlib/Util/MemoFix.lean

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ public import Mathlib.Init
1515

1616
variable {α β : Type}
1717

18-
@[noinline]
18+
@[noinline, deprecated "deprecated without replacement" (since := "2026-01-24")]
1919
def injectIntoBaseIO {α : Type} (a : α) : BaseIO α := pure a
2020

21+
set_option linter.deprecated false in
22+
@[deprecated "deprecated without replacement" (since := "2026-01-24")]
2123
unsafe def memoFixImpl [Nonempty β] (f : (α → β) → (α → β)) : α → β := unsafeBaseIO do
2224
let cache : IO.Ref (Lean.PtrMap α β) ← ST.mkRef Lean.mkPtrMap
2325
let rec fix (a) : β := unsafeBaseIO do
@@ -34,5 +36,6 @@ Hashing makes use of a pointer hash.
3436
This is useful for implementing tree traversal functions where
3537
subtrees may be referenced in multiple places.
3638
-/
37-
@[implemented_by memoFixImpl]
39+
@[implemented_by memoFixImpl,
40+
deprecated "use `MonadCacheT` and `checkCache`" (since := "2026-01-24")]
3841
public opaque memoFix [Nonempty β] (f : (α → β) → (α → β)) : α → β

MathlibTest/Expr.lean

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)