@@ -93,17 +93,19 @@ theorem add_top_of_ne_bot {x : EReal} (h : x ≠ ⊥) : x + ⊤ = ⊤ := by
93
93
if and only if `x` is not `⊥`. -/
94
94
theorem add_top_iff_ne_bot {x : EReal} : x + ⊤ = ⊤ ↔ x ≠ ⊥ := by rw [add_comm, top_add_iff_ne_bot]
95
95
96
+ protected theorem add_pos_of_nonneg_of_pos {a b : EReal} (ha : 0 ≤ a) (hb : 0 < b) : 0 < a + b := by
97
+ lift a to ℝ≥0 ∞ using ha
98
+ lift b to ℝ≥0 ∞ using hb.le
99
+ norm_cast at *
100
+ simp [hb]
101
+
102
+ protected theorem add_pos_of_pos_of_nonneg {a b : EReal} (ha : 0 < a) (hb : 0 ≤ b) : 0 < a + b :=
103
+ add_comm a b ▸ EReal.add_pos_of_nonneg_of_pos hb ha
104
+
96
105
/-- For any two extended real numbers `a` and `b`, if both `a` and `b` are greater than `0`,
97
106
then their sum is also greater than `0`. -/
98
- theorem add_pos {a b : EReal} (ha : 0 < a) (hb : 0 < b) : 0 < a + b := by
99
- induction a
100
- · exfalso; exact not_lt_bot ha
101
- · induction b
102
- · exfalso; exact not_lt_bot hb
103
- · norm_cast at *; exact Left.add_pos ha hb
104
- · exact add_top_of_ne_bot (bot_lt_zero.trans ha).ne' ▸ hb
105
- · rw [top_add_of_ne_bot (bot_lt_zero.trans hb).ne']
106
- exact ha
107
+ protected theorem add_pos {a b : EReal} (ha : 0 < a) (hb : 0 < b) : 0 < a + b :=
108
+ EReal.add_pos_of_nonneg_of_pos ha.le hb
107
109
108
110
@[simp]
109
111
theorem coe_add_top (x : ℝ) : (x : EReal) + ⊤ = ⊤ :=
@@ -294,6 +296,11 @@ protected theorem neg_lt_of_neg_lt {a b : EReal} (h : -a < b) : -b < a := neg_lt
294
296
theorem lt_neg_comm {a b : EReal} : a < -b ↔ b < -a := by
295
297
rw [← neg_lt_neg_iff, neg_neg]
296
298
299
+ @[simp] protected theorem neg_lt_zero {a : EReal} : -a < 0 ↔ 0 < a := by rw [neg_lt_comm, neg_zero]
300
+ @[simp] protected theorem neg_le_zero {a : EReal} : -a ≤ 0 ↔ 0 ≤ a := by rw [EReal.neg_le, neg_zero]
301
+ @[simp] protected theorem neg_pos {a : EReal} : 0 < -a ↔ a < 0 := by rw [lt_neg_comm, neg_zero]
302
+ @[simp] protected theorem neg_nonneg {a : EReal} : 0 ≤ -a ↔ a ≤ 0 := by rw [EReal.le_neg, neg_zero]
303
+
297
304
/-- If `a < -b` then `b < -a` on `EReal`. -/
298
305
protected theorem lt_neg_of_lt_neg {a b : EReal} (h : a < -b) : b < -a := lt_neg_comm.mp h
299
306
@@ -313,6 +320,31 @@ lemma neg_sub {x y : EReal} (h1 : x ≠ ⊥ ∨ y ≠ ⊥) (h2 : x ≠ ⊤ ∨ y
313
320
- (x - y) = - x + y := by
314
321
rw [sub_eq_add_neg, neg_add _ _, sub_eq_add_neg, neg_neg] <;> simp_all
315
322
323
+ /-- Induction principle for `EReal`s splitting into cases `↑(x : ℝ≥0∞)` and `-↑(x : ℝ≥0∞)`.
324
+ In the latter case, we additionally assume `0 < x`. -/
325
+ @[elab_as_elim]
326
+ def recENNReal {motive : EReal → Sort *} (coe : ∀ x : ℝ≥0 ∞, motive x)
327
+ (neg_coe : ∀ x : ℝ≥0 ∞, 0 < x → motive (-x)) (x : EReal) : motive x :=
328
+ if hx : 0 ≤ x then coe_toENNReal hx ▸ coe _
329
+ else
330
+ have H₁ : 0 < -x := by simpa using hx
331
+ have H₂ : x = -(-x).toENNReal := by rw [coe_toENNReal H₁.le, neg_neg]
332
+ H₂ ▸ neg_coe _ <| by simp [H₁]
333
+
334
+ @[simp]
335
+ theorem recENNReal_coe_ennreal {motive : EReal → Sort *} (coe : ∀ x : ℝ≥0 ∞, motive x)
336
+ (neg_coe : ∀ x : ℝ≥0 ∞, 0 < x → motive (-x)) (x : ℝ≥0 ∞) : recENNReal coe neg_coe x = coe x := by
337
+ suffices ∀ y : EReal, x = y → HEq (recENNReal coe neg_coe y : motive y) (coe x) from
338
+ heq_iff_eq.mp (this x rfl)
339
+ intro y hy
340
+ have H₁ : 0 ≤ y := hy ▸ coe_ennreal_nonneg x
341
+ obtain rfl : y.toENNReal = x := by simp [← hy]
342
+ simp [recENNReal, H₁]
343
+
344
+ proof_wanted recENNReal_neg_coe_ennreal {motive : EReal → Sort *} (coe : ∀ x : ℝ≥0 ∞, motive x)
345
+ (neg_coe : ∀ x : ℝ≥0 ∞, 0 < x → motive (-x)) {x : ℝ≥0 ∞} (hx : 0 < x) :
346
+ recENNReal coe neg_coe (-x) = neg_coe x hx
347
+
316
348
/-!
317
349
### Subtraction
318
350
@@ -639,8 +671,11 @@ lemma mul_nonneg_iff {a b : EReal} : 0 ≤ a * b ↔ 0 ≤ a ∧ 0 ≤ b ∨ a
639
671
rcases lt_trichotomy a 0 with (h | h | h) <;> rcases lt_trichotomy b 0 with (h' | h' | h')
640
672
<;> simp only [h, h', true_or, true_and, or_true, and_true] <;> tauto
641
673
674
+ protected lemma mul_nonneg {a b : EReal} (ha : 0 ≤ a) (hb : 0 ≤ b) : 0 ≤ a * b :=
675
+ mul_nonneg_iff.mpr <| .inl ⟨ha, hb⟩
676
+
642
677
/-- The product of two positive extended real numbers is positive. -/
643
- lemma mul_pos {a b : EReal} (ha : 0 < a) (hb : 0 < b) : 0 < a * b :=
678
+ protected lemma mul_pos {a b : EReal} (ha : 0 < a) (hb : 0 < b) : 0 < a * b :=
644
679
mul_pos_iff.mpr (Or.inl ⟨ha, hb⟩)
645
680
646
681
/-- Induct on two ereals by performing case splits on the sign of one whenever the other is
@@ -772,38 +807,14 @@ lemma toENNReal_mul' {x y : EReal} (hy : 0 ≤ y) :
772
807
773
808
lemma right_distrib_of_nonneg {a b c : EReal} (ha : 0 ≤ a) (hb : 0 ≤ b) :
774
809
(a + b) * c = a * c + b * c := by
775
- rcases eq_or_lt_of_le ha with (rfl | a_pos)
776
- · simp
777
- rcases eq_or_lt_of_le hb with (rfl | b_pos)
778
- · simp
779
- rcases lt_trichotomy c 0 with (c_neg | rfl | c_pos)
780
- · induction c
781
- · rw [mul_bot_of_pos a_pos, mul_bot_of_pos b_pos, mul_bot_of_pos (add_pos a_pos b_pos),
782
- add_bot ⊥]
783
- · induction a
784
- · exfalso; exact not_lt_bot a_pos
785
- · induction b
786
- · norm_cast
787
- · norm_cast; exact right_distrib _ _ _
788
- · norm_cast
789
- rw [add_top_of_ne_bot (coe_ne_bot _), top_mul_of_neg c_neg, add_bot]
790
- · rw [top_add_of_ne_bot (ne_bot_of_gt b_pos), top_mul_of_neg c_neg, bot_add]
791
- · exfalso; exact not_top_lt c_neg
792
- · simp
793
- · induction c
794
- · exfalso; exact not_lt_bot c_pos
795
- · induction a
796
- · exfalso; exact not_lt_bot a_pos
797
- · induction b
798
- · norm_cast
799
- · norm_cast; exact right_distrib _ _ _
800
- · norm_cast
801
- rw [add_top_of_ne_bot (coe_ne_bot _), top_mul_of_pos c_pos,
802
- add_top_of_ne_bot (coe_ne_bot _)]
803
- · rw [top_add_of_ne_bot (ne_bot_of_gt b_pos), top_mul_of_pos c_pos,
804
- top_add_of_ne_bot (ne_bot_of_gt (mul_pos b_pos c_pos))]
805
- · rw [mul_top_of_pos a_pos, mul_top_of_pos b_pos, mul_top_of_pos (add_pos a_pos b_pos),
806
- top_add_top]
810
+ lift a to ℝ≥0 ∞ using ha
811
+ lift b to ℝ≥0 ∞ using hb
812
+ cases c using recENNReal with
813
+ | coe c => exact_mod_cast add_mul a b c
814
+ | neg_coe c hc =>
815
+ simp only [mul_neg, ← coe_ennreal_add, ← coe_ennreal_mul, add_mul]
816
+ rw [coe_ennreal_add, EReal.neg_add (.inl (coe_ennreal_ne_bot _)) (.inr (coe_ennreal_ne_bot _)),
817
+ sub_eq_add_neg]
807
818
808
819
lemma left_distrib_of_nonneg {a b c : EReal} (ha : 0 ≤ a) (hb : 0 ≤ b) :
809
820
c * (a + b) = c * a + c * b := by
0 commit comments