Skip to content

Commit 715f3e1

Browse files
YaelDilliesb-mehta
authored andcommitted
feat(Data/NNReal): nnabs n = n for n : ℕ (leanprover-community#39577)
From MeanFourier
1 parent 029af28 commit 715f3e1

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

Mathlib/Data/NNReal/Defs.lean

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,15 @@ theorem mk_natCast (n : ℕ) : NNReal.mk (n : ℝ) (n.cast_nonneg) = n :=
355355
NNReal.eq (NNReal.coe_natCast n).symm
356356

357357
@[simp]
358-
theorem _root_.Real.toNNReal_coe_nat (n : ℕ) : Real.toNNReal n = n :=
358+
theorem _root_.Real.toNNReal_natCast (n : ℕ) : Real.toNNReal n = n :=
359359
NNReal.eq <| by simp [Real.coe_toNNReal]
360360

361+
@[deprecated (since := "2026-05-19")] alias _root_.Real.toNNReal_coe_nat := Real.toNNReal_natCast
362+
361363
@[simp]
362364
theorem _root_.Real.toNNReal_ofNat (n : ℕ) [n.AtLeastTwo] :
363365
Real.toNNReal ofNat(n) = OfNat.ofNat n :=
364-
Real.toNNReal_coe_nat n
366+
Real.toNNReal_natCast n
365367

366368
/-- `Real.toNNReal` and `NNReal.toReal : ℝ≥0 → ℝ` form a Galois insertion. -/
367369
def gi : GaloisInsertion Real.toNNReal (↑) :=
@@ -910,6 +912,9 @@ theorem coe_toNNReal_le (x : ℝ) : (toNNReal x : ℝ) ≤ |x| :=
910912

911913
@[simp] lemma toNNReal_abs (x : ℝ) : |x|.toNNReal = nnabs x := NNReal.coe_injective <| by simp
912914

915+
@[simp high] lemma nnabs_natCast (n : ℕ) : nnabs n = n := by simp
916+
@[simp high] lemma nnabs_ofNat (n : ℕ) [n.AtLeastTwo] : nnabs ofNat(n) = ofNat(n) := by simp
917+
913918
theorem cast_natAbs_eq_nnabs_cast (n : ℤ) : (n.natAbs : ℝ≥0) = nnabs n := by
914919
ext
915920
rw [NNReal.coe_natCast, Nat.cast_natAbs, Real.coe_nnabs, Int.cast_abs]

0 commit comments

Comments
 (0)