Skip to content

Commit b965444

Browse files
committed
doc: describe why map_ofNat can't be simp (yet) (#19410)
See the benchmark in #19388, which while not disastrous is not ideal either. Unless the situation changes with leanprover/lean4#2867, the DiscrTree key would apply to all funlike operations applied to any argument, not just applied to numerals.
1 parent 725d2de commit b965444

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Mathlib/Data/Nat/Cast/Basic.lean

+5
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ theorem eq_natCast [FunLike F ℕ R] [RingHomClass F ℕ R] (f : F) : ∀ n, f n
159159
theorem map_natCast [FunLike F R S] [RingHomClass F R S] (f : F) : ∀ n : ℕ, f (n : R) = n :=
160160
map_natCast' f <| map_one f
161161

162+
/-- This lemma is not marked `@[simp]` lemma because its `#discr_tree_key` (for the LHS) would just
163+
be `DFunLike.coe _ _`, due to the `no_index` that https://github.com/leanprover/lean4/issues/2867
164+
forces us to include, and therefore it would negatively impact performance.
165+
166+
If that issue is resolved, this can be marked `@[simp]`. -/
162167
theorem map_ofNat [FunLike F R S] [RingHomClass F R S] (f : F) (n : ℕ) [Nat.AtLeastTwo n] :
163168
(f (no_index (OfNat.ofNat n)) : S) = OfNat.ofNat n :=
164169
map_natCast f n

0 commit comments

Comments
 (0)