@@ -683,6 +683,90 @@ theorem coe_ennreal_mul : ∀ x y : ℝ≥0∞, ((x * y : ℝ≥0∞) : EReal) =
683
683
theorem coe_ennreal_nsmul (n : ℕ) (x : ℝ≥0 ∞) : (↑(n • x) : EReal) = n • (x : EReal) :=
684
684
map_nsmul (⟨⟨(↑), coe_ennreal_zero⟩, coe_ennreal_add⟩ : ℝ≥0 ∞ →+ EReal) _ _
685
685
686
+ /-! ### toENNReal -/
687
+
688
+ /-- `x.toENNReal` returns `x` if it is nonnegative, `0` otherwise. -/
689
+ noncomputable def toENNReal (x : EReal) : ℝ≥0 ∞ :=
690
+ if x = ⊤ then ⊤
691
+ else ENNReal.ofReal x.toReal
692
+
693
+ @[simp] lemma toENNReal_top : (⊤ : EReal).toENNReal = ⊤ := rfl
694
+
695
+ @[simp]
696
+ lemma toENNReal_of_ne_top {x : EReal} (hx : x ≠ ⊤) : x.toENNReal = ENNReal.ofReal x.toReal :=
697
+ if_neg hx
698
+
699
+ @[simp]
700
+ lemma toENNReal_eq_top_iff {x : EReal} : x.toENNReal = ⊤ ↔ x = ⊤ := by
701
+ by_cases h : x = ⊤
702
+ · simp [h]
703
+ · simp [h, toENNReal]
704
+
705
+ lemma toENNReal_ne_top_iff {x : EReal} : x.toENNReal ≠ ⊤ ↔ x ≠ ⊤ := toENNReal_eq_top_iff.not
706
+
707
+ @[simp]
708
+ lemma toENNReal_of_nonpos {x : EReal} (hx : x ≤ 0 ) : x.toENNReal = 0 := by
709
+ rw [toENNReal, if_neg (fun h ↦ ?_)]
710
+ · exact ENNReal.ofReal_of_nonpos (toReal_nonpos hx)
711
+ · exact zero_ne_top <| top_le_iff.mp <| h ▸ hx
712
+
713
+ lemma toENNReal_bot : (⊥ : EReal).toENNReal = 0 := toENNReal_of_nonpos bot_le
714
+ lemma toENNReal_zero : (0 : EReal).toENNReal = 0 := toENNReal_of_nonpos le_rfl
715
+
716
+ lemma toENNReal_eq_zero_iff {x : EReal} : x.toENNReal = 0 ↔ x ≤ 0 := by
717
+ induction x <;> simp [toENNReal]
718
+
719
+ lemma toENNReal_ne_zero_iff {x : EReal} : x.toENNReal ≠ 0 ↔ 0 < x := by
720
+ simp [toENNReal_eq_zero_iff.not]
721
+
722
+ @[simp]
723
+ lemma coe_toENNReal {x : EReal} (hx : 0 ≤ x) : (x.toENNReal : EReal) = x := by
724
+ rw [toENNReal]
725
+ by_cases h_top : x = ⊤
726
+ · rw [if_pos h_top, h_top]
727
+ rfl
728
+ rw [if_neg h_top]
729
+ simp only [coe_ennreal_ofReal, ge_iff_le, hx, toReal_nonneg, max_eq_left]
730
+ exact coe_toReal h_top fun _ ↦ by simp_all only [le_bot_iff, zero_ne_bot]
731
+
732
+ lemma coe_toENNReal_eq_max {x : EReal} : x.toENNReal = max 0 x := by
733
+ rcases le_total 0 x with (hx | hx)
734
+ · rw [coe_toENNReal hx, max_eq_right hx]
735
+ · rw [toENNReal_of_nonpos hx, max_eq_left hx, coe_ennreal_zero]
736
+
737
+ @[simp]
738
+ lemma toENNReal_coe {x : ℝ≥0 ∞} : (x : EReal).toENNReal = x := by
739
+ by_cases h_top : x = ⊤
740
+ · rw [h_top, coe_ennreal_top, toENNReal_top]
741
+ rwa [toENNReal, if_neg _, toReal_coe_ennreal, ENNReal.ofReal_toReal_eq_iff]
742
+ simp [h_top]
743
+
744
+ @[simp] lemma real_coe_toENNReal (x : ℝ) : (x : EReal).toENNReal = ENNReal.ofReal x := rfl
745
+
746
+ @[simp]
747
+ lemma toReal_toENNReal {x : EReal} (hx : 0 ≤ x) : x.toENNReal.toReal = x.toReal := by
748
+ by_cases h : x = ⊤
749
+ · simp [h]
750
+ · simp [h, toReal_nonneg hx]
751
+
752
+ lemma toENNReal_eq_toENNReal {x y : EReal} (hx : 0 ≤ x) (hy : 0 ≤ y) :
753
+ x.toENNReal = y.toENNReal ↔ x = y := by
754
+ induction x <;> induction y <;> simp_all
755
+
756
+ lemma toENNReal_le_toENNReal {x y : EReal} (h : x ≤ y) : x.toENNReal ≤ y.toENNReal := by
757
+ induction x
758
+ · simp
759
+ · by_cases hy_top : y = ⊤
760
+ · simp [hy_top]
761
+ simp only [toENNReal, coe_ne_top, ↓reduceIte, toReal_coe, hy_top]
762
+ exact ENNReal.ofReal_le_ofReal <| EReal.toReal_le_toReal h (coe_ne_bot _) hy_top
763
+ · simp_all
764
+
765
+ lemma toENNReal_lt_toENNReal {x y : EReal} (hx : 0 ≤ x) (hxy : x < y) :
766
+ x.toENNReal < y.toENNReal :=
767
+ lt_of_le_of_ne (toENNReal_le_toENNReal hxy.le)
768
+ fun h ↦ hxy.ne <| (toENNReal_eq_toENNReal hx (hx.trans_lt hxy).le).mp h
769
+
686
770
/-! ### nat coercion -/
687
771
688
772
theorem coe_coe_eq_natCast (n : ℕ) : (n : ℝ) = (n : EReal) := rfl
@@ -826,6 +910,17 @@ theorem toReal_add {x y : EReal} (hx : x ≠ ⊤) (h'x : x ≠ ⊥) (hy : y ≠
826
910
lift y to ℝ using ⟨hy, h'y⟩
827
911
rfl
828
912
913
+ lemma toENNReal_add {x y : EReal} (hx : 0 ≤ x) (hy : 0 ≤ y) :
914
+ (x + y).toENNReal = x.toENNReal + y.toENNReal := by
915
+ induction x <;> induction y <;> try {· simp_all}
916
+ norm_cast
917
+ simp_rw [real_coe_toENNReal]
918
+ simp_all [ENNReal.ofReal_add]
919
+
920
+ lemma toENNReal_add_le {x y : EReal} : (x + y).toENNReal ≤ x.toENNReal + y.toENNReal := by
921
+ induction x <;> induction y <;> try {· simp}
922
+ exact ENNReal.ofReal_add_le
923
+
829
924
theorem addLECancellable_coe (x : ℝ) : AddLECancellable (x : EReal)
830
925
| _, ⊤, _ => le_top
831
926
| ⊥, _, _ => bot_le
@@ -885,6 +980,16 @@ lemma add_ne_top_iff_ne_top_left {x y : EReal} (hy : y ≠ ⊥) (hy' : y ≠ ⊤
885
980
lemma add_ne_top_iff_ne_top_right {x y : EReal} (hx : x ≠ ⊥) (hx' : x ≠ ⊤) :
886
981
x + y ≠ ⊤ ↔ y ≠ ⊤ := add_comm x y ▸ add_ne_top_iff_ne_top_left hx hx'
887
982
983
+ lemma add_ne_top_iff_of_ne_bot {x y : EReal} (hx : x ≠ ⊥) (hy : y ≠ ⊥) :
984
+ x + y ≠ ⊤ ↔ x ≠ ⊤ ∧ y ≠ ⊤ := by
985
+ refine ⟨?_, fun h ↦ add_ne_top h.1 h.2 ⟩
986
+ induction x <;> simp_all
987
+ induction y <;> simp_all
988
+
989
+ lemma add_ne_top_iff_of_ne_bot_of_ne_top {x y : EReal} (hy : y ≠ ⊥) (hy' : y ≠ ⊤) :
990
+ x + y ≠ ⊤ ↔ x ≠ ⊤ := by
991
+ induction x <;> simp [add_ne_top_iff_of_ne_bot, hy, hy']
992
+
888
993
/-- We do not have a notion of `LinearOrderedAddCommMonoidWithBot` but we can at least make
889
994
the order dual of the extended reals into a `LinearOrderedAddCommMonoidWithTop`. -/
890
995
instance : LinearOrderedAddCommMonoidWithTop ERealᵒᵈ where
@@ -1084,6 +1189,17 @@ theorem toReal_sub {x y : EReal} (hx : x ≠ ⊤) (h'x : x ≠ ⊥) (hy : y ≠
1084
1189
lift y to ℝ using ⟨hy, h'y⟩
1085
1190
rfl
1086
1191
1192
+ lemma toENNReal_sub {x y : EReal} (hy : 0 ≤ y) :
1193
+ (x - y).toENNReal = x.toENNReal - y.toENNReal := by
1194
+ induction x <;> induction y <;> try {· simp_all [zero_tsub, ENNReal.sub_top]}
1195
+ rename_i x y
1196
+ by_cases hxy : x ≤ y
1197
+ · rw [toENNReal_of_nonpos <| sub_nonpos.mpr <| EReal.coe_le_coe_iff.mpr hxy]
1198
+ exact (tsub_eq_zero_of_le <| toENNReal_le_toENNReal <| EReal.coe_le_coe_iff.mpr hxy).symm
1199
+ · rw [toENNReal_of_ne_top (ne_of_beq_false rfl).symm, ← coe_sub, toReal_coe,
1200
+ ofReal_sub x (EReal.coe_nonneg.mp hy)]
1201
+ simp
1202
+
1087
1203
lemma add_sub_cancel_right {a : EReal} {b : Real} : a + b - b = a := by
1088
1204
cases a <;> norm_cast
1089
1205
exact _root_.add_sub_cancel_right _ _
@@ -1428,6 +1544,27 @@ lemma mul_ne_bot (a b : EReal) :
1428
1544
set_option push_neg.use_distrib true in push_neg
1429
1545
rfl
1430
1546
1547
+ /-- `EReal.toENNReal` is multiplicative. For the version with the nonnegativity
1548
+ hypothesis on the second variable, see `EReal.toENNReal_mul'`. -/
1549
+ lemma toENNReal_mul {x y : EReal} (hx : 0 ≤ x) :
1550
+ (x * y).toENNReal = x.toENNReal * y.toENNReal := by
1551
+ induction x <;> induction y
1552
+ <;> try {· simp_all [mul_nonpos_iff, ofReal_mul, ← coe_mul]}
1553
+ · rcases eq_or_lt_of_le hx with (hx | hx)
1554
+ · simp [← hx]
1555
+ · simp_all [mul_top_of_pos hx]
1556
+ · rename_i a
1557
+ rcases lt_trichotomy a 0 with (ha | ha | ha)
1558
+ · simp_all [le_of_lt, top_mul_of_neg (EReal.coe_neg'.mpr ha)]
1559
+ · simp [ha]
1560
+ · simp_all [top_mul_of_pos (EReal.coe_pos.mpr ha)]
1561
+
1562
+ /-- `EReal.toENNReal` is multiplicative. For the version with the nonnegativity
1563
+ hypothesis on the first variable, see `EReal.toENNReal_mul`. -/
1564
+ lemma toENNReal_mul' {x y : EReal} (hy : 0 ≤ y) :
1565
+ (x * y).toENNReal = x.toENNReal * y.toENNReal := by
1566
+ rw [EReal.mul_comm, toENNReal_mul hy, mul_comm]
1567
+
1431
1568
lemma right_distrib_of_nonneg {a b c : EReal} (ha : 0 ≤ a) (hb : 0 ≤ b) :
1432
1569
(a + b) * c = a * c + b * c := by
1433
1570
rcases eq_or_lt_of_le ha with (rfl | a_pos)
@@ -1946,4 +2083,4 @@ unsafe def positivity_coe_ennreal_ereal : expr → tactic strictness
1946
2083
end Tactic
1947
2084
-/
1948
2085
1949
- set_option linter.style.longFile 2000
2086
+ set_option linter.style.longFile 2200
0 commit comments