Zulip Chat Archive
Stream: new members
Topic: Is there an ENNReal.natCast_div?
Ching-Tsun Chou (Jan 23 2025 at 05:05):
Is there a theorem like:
but with the subtraction replaced by division and perhaps a side-condition that the divisor must be positive?
Yaël Dillies (Jan 23 2025 at 09:21):
1 / 2 = 0
in ℕ
, so no there isn't. One could state ↑(a / b) = ↑a / ↑b
if b ∣ a
, but we don't seem to have that either. PR welcome!
Ching-Tsun Chou (Jan 24 2025 at 00:29):
Good point. I think the a and b in a/b are cast to Real first before the /. So I was looking at the wrong theorems.
Igor Khavkine (Jan 25 2025 at 00:18):
FYI, here's something like a response to the original request:
import Mathlib.Data.Rat.Init
import Mathlib.Data.ENNReal.Inv
def ENNReal.natCast_div (m n : ℕ) (hn : n ≠ 0) : ↑(NNRat.divNat m n) = (↑m : ENNReal) / ↑n := by
have recast_rat (nnr : NNRat) : ↑nnr = (↑(↑nnr : NNReal) : ENNReal) := rfl
have recast_nat (n : Nat) : ↑n = (↑(↑(↑n : NNRat) : NNReal) : ENNReal) := rfl
repeat rw [recast_nat]
rw [recast_rat, ← ENNReal.coe_div, ← NNRat.cast_div]
congr; exact NNRat.cast_divNat _ _
norm_cast
Ching-Tsun Chou (Jan 25 2025 at 00:55):
Thanks! In the end I figured out what lemma I actually needed:
#new members > How do I prove this lemma?
Last updated: May 02 2025 at 03:31 UTC