@@ -53,7 +53,7 @@ open function
53
53
open_locale ennreal nnreal
54
54
55
55
/-- ereal : The type `[-∞, ∞]` -/
56
- @[derive [has_top, comm_monoid_with_zero, nontrivial,
56
+ @[derive [has_top, comm_monoid_with_zero, nontrivial, add_monoid,
57
57
has_Sup, has_Inf, complete_linear_order, linear_ordered_add_comm_monoid_with_top] ]
58
58
def ereal := with_top (with_bot ℝ)
59
59
@@ -66,9 +66,6 @@ namespace ereal
66
66
-- TODO: Provide explicitly, otherwise it is inferred noncomputably from `complete_linear_order`
67
67
instance : has_bot ereal := ⟨some ⊥⟩
68
68
69
- @[simp] lemma bot_lt_top : (⊥ : ereal) < ⊤ := with_top.coe_lt_top _
70
- @[simp] lemma bot_ne_top : (⊥ : ereal) ≠ ⊤ := bot_lt_top.ne
71
-
72
69
instance : has_coe ℝ ereal := ⟨real.to_ereal⟩
73
70
74
71
lemma coe_strict_mono : strict_mono (coe : ℝ → ereal) :=
@@ -157,10 +154,18 @@ by { apply with_top.coe_lt_coe.2, exact with_bot.bot_lt_coe _ }
157
154
158
155
@[simp] lemma top_ne_zero : (⊤ : ereal) ≠ 0 := (coe_ne_top 0 ).symm
159
156
160
- @[simp, norm_cast] lemma coe_add (x y : ℝ) : ((x + y : ℝ) : ereal) = (x : ereal) + (y : ereal) :=
161
- rfl
162
-
163
157
@[simp, norm_cast] lemma coe_zero : ((0 : ℝ) : ereal) = 0 := rfl
158
+ @[simp, norm_cast] lemma coe_one : ((1 : ℝ) : ereal) = 1 := rfl
159
+ @[simp, norm_cast] lemma coe_add (x y : ℝ) : (↑(x + y) : ereal) = x + y := rfl
160
+ @[simp, norm_cast] lemma coe_mul (x y : ℝ) : (↑(x * y) : ereal) = x * y :=
161
+ (with_top.coe_eq_coe.2 with_bot.coe_mul).trans with_top.coe_mul
162
+ @[norm_cast] lemma coe_nsmul (n : ℕ) (x : ℝ) : (↑(n • x) : ereal) = n • x :=
163
+ map_nsmul (⟨coe, coe_zero, coe_add⟩ : ℝ →+ ereal) _ _
164
+ @[simp, norm_cast] lemma coe_pow (x : ℝ) (n : ℕ) : (↑(x ^ n) : ereal) = x ^ n :=
165
+ map_pow (⟨coe, coe_one, coe_mul⟩ : ℝ →* ereal) _ _
166
+
167
+ @[simp, norm_cast] lemma coe_bit0 (x : ℝ) : (↑(bit0 x) : ereal) = bit0 x := rfl
168
+ @[simp, norm_cast] lemma coe_bit1 (x : ℝ) : (↑(bit1 x) : ereal) = bit1 x := rfl
164
169
165
170
@[simp, norm_cast] lemma coe_eq_zero {x : ℝ} : (x : ereal) = 0 ↔ x = 0 := ereal.coe_eq_coe_iff
166
171
@[simp, norm_cast] lemma coe_eq_one {x : ℝ} : (x : ereal) = 1 ↔ x = 1 := ereal.coe_eq_coe_iff
@@ -249,25 +254,28 @@ lemma coe_nnreal_ne_top (x : ℝ≥0) : ((x : ℝ≥0∞) : ereal) ≠ ⊤ := de
249
254
250
255
@[simp] lemma coe_nnreal_lt_top (x : ℝ≥0 ) : ((x : ℝ≥0 ∞) : ereal) < ⊤ := dec_trivial
251
256
252
- @[simp, norm_cast] lemma coe_ennreal_le_coe_ennreal_iff : ∀ {x y : ℝ≥0 ∞},
253
- (x : ereal) ≤ (y : ereal) ↔ x ≤ y
254
- | x ⊤ := by simp
255
- | ⊤ (some y) := by simp
256
- | (some x) (some y) := by simp [coe_nnreal_eq_coe_real]
257
-
258
- @[simp, norm_cast] lemma coe_ennreal_lt_coe_ennreal_iff : ∀ {x y : ℝ≥0 ∞},
259
- (x : ereal) < (y : ereal) ↔ x < y
257
+ lemma coe_ennreal_strict_mono : strict_mono (coe : ℝ≥0 ∞ → ereal)
260
258
| ⊤ ⊤ := by simp
261
259
| (some x) ⊤ := by simp
262
260
| ⊤ (some y) := by simp
263
261
| (some x) (some y) := by simp [coe_nnreal_eq_coe_real]
264
262
265
- @[simp, norm_cast] lemma coe_ennreal_eq_coe_ennreal_iff : ∀ {x y : ℝ≥0 ∞},
266
- (x : ereal) = (y : ereal) ↔ x = y
267
- | ⊤ ⊤ := by simp
268
- | (some x) ⊤ := by simp
269
- | ⊤ (some y) := by simp [(coe_nnreal_lt_top y).ne']
270
- | (some x) (some y) := by simp [coe_nnreal_eq_coe_real]
263
+ lemma coe_ennreal_injective : injective (coe : ℝ≥0 ∞ → ereal) := coe_ennreal_strict_mono.injective
264
+
265
+ @[simp, norm_cast] lemma coe_ennreal_le_coe_ennreal_iff {x y : ℝ≥0 ∞} :
266
+ (x : ereal) ≤ (y : ereal) ↔ x ≤ y :=
267
+ coe_ennreal_strict_mono.le_iff_le
268
+
269
+ @[simp, norm_cast] lemma coe_ennreal_lt_coe_ennreal_iff {x y : ℝ≥0 ∞} :
270
+ (x : ereal) < (y : ereal) ↔ x < y :=
271
+ coe_ennreal_strict_mono.lt_iff_lt
272
+
273
+ @[simp, norm_cast] lemma coe_ennreal_eq_coe_ennreal_iff {x y : ℝ≥0 ∞} :
274
+ (x : ereal) = (y : ereal) ↔ x = y :=
275
+ coe_ennreal_injective.eq_iff
276
+
277
+ lemma coe_ennreal_ne_coe_ennreal_iff {x y : ℝ≥0 ∞} : (x : ereal) ≠ (y : ereal) ↔ x ≠ y :=
278
+ coe_ennreal_injective.ne_iff
271
279
272
280
@[simp, norm_cast] lemma coe_ennreal_eq_zero {x : ℝ≥0 ∞} : (x : ereal) = 0 ↔ x = 0 :=
273
281
by rw [←coe_ennreal_eq_coe_ennreal_iff, coe_ennreal_zero]
@@ -296,6 +304,21 @@ by rw [←coe_ennreal_zero, coe_ennreal_lt_coe_ennreal_iff]
296
304
| x ⊤ := by simp
297
305
| (some x) (some y) := rfl
298
306
307
+ @[simp, norm_cast] lemma coe_ennreal_mul : ∀ (x y : ℝ≥0 ∞), ((x * y : ℝ≥0 ∞) : ereal) = x * y
308
+ | ⊤ y := by { rw ennreal.top_mul, split_ifs; simp [h] }
309
+ | x ⊤ := by { rw ennreal.mul_top, split_ifs; simp [h] }
310
+ | (some x) (some y) := by simp [←ennreal.coe_mul, coe_nnreal_eq_coe_real]
311
+
312
+ @[norm_cast] lemma coe_ennreal_nsmul (n : ℕ) (x : ℝ≥0 ∞) : (↑(n • x) : ereal) = n • x :=
313
+ map_nsmul (⟨coe, coe_ennreal_zero, coe_ennreal_add⟩ : ℝ≥0 ∞ →+ ereal) _ _
314
+
315
+ @[simp, norm_cast] lemma coe_ennreal_pow (x : ℝ≥0 ∞) (n : ℕ) : (↑(x ^ n) : ereal) = x ^ n :=
316
+ map_pow (⟨coe, coe_ennreal_one, coe_ennreal_mul⟩ : ℝ≥0 ∞ →* ereal) _ _
317
+
318
+ @[simp, norm_cast] lemma coe_ennreal_bit0 (x : ℝ≥0 ∞) : (↑(bit0 x) : ereal) = bit0 x :=
319
+ coe_ennreal_add _ _
320
+ @[simp, norm_cast] lemma coe_ennreal_bit1 (x : ℝ≥0 ∞) : (↑(bit1 x) : ereal) = bit1 x :=
321
+ by simp_rw [bit1, coe_ennreal_add, coe_ennreal_bit0, coe_ennreal_one]
299
322
300
323
/-! ### Order -/
301
324
@@ -401,11 +424,20 @@ protected def neg : ereal → ereal
401
424
402
425
instance : has_neg ereal := ⟨ereal.neg⟩
403
426
427
+ instance : sub_neg_zero_monoid ereal :=
428
+ { neg_zero := by { change ((-0 : ℝ) : ereal) = 0 , simp },
429
+ ..ereal.add_monoid, ..ereal.has_neg }
430
+
404
431
@[norm_cast] protected lemma neg_def (x : ℝ) : ((-x : ℝ) : ereal) = -x := rfl
405
432
406
433
@[simp] lemma neg_top : - (⊤ : ereal) = ⊥ := rfl
407
434
@[simp] lemma neg_bot : - (⊥ : ereal) = ⊤ := rfl
408
435
436
+ @[simp, norm_cast] lemma coe_neg (x : ℝ) : (↑(-x) : ereal) = -x := rfl
437
+ @[simp, norm_cast] lemma coe_sub (x y : ℝ) : (↑(x - y) : ereal) = x - y := rfl
438
+ @[norm_cast] lemma coe_zsmul (n : ℤ) (x : ℝ) : (↑(n • x) : ereal) = n • x :=
439
+ map_zsmul' (⟨coe, coe_zero, coe_add⟩ : ℝ →+ ereal) coe_neg _ _
440
+
409
441
instance : has_involutive_neg ereal :=
410
442
{ neg := has_neg.neg,
411
443
neg_neg := λ a, match a with
@@ -419,14 +451,14 @@ instance : has_involutive_neg ereal :=
419
451
| ⊥ := by simp
420
452
| (x : ℝ) := rfl
421
453
422
- @[simp] lemma neg_eg_top_iff {x : ereal} : - x = ⊤ ↔ x = ⊥ :=
454
+ @[simp] lemma neg_eq_top_iff {x : ereal} : - x = ⊤ ↔ x = ⊥ :=
423
455
by { rw neg_eq_iff_neg_eq, simp [eq_comm] }
424
456
425
- @[simp] lemma neg_eg_bot_iff {x : ereal} : - x = ⊥ ↔ x = ⊤ :=
457
+ @[simp] lemma neg_eq_bot_iff {x : ereal} : - x = ⊥ ↔ x = ⊤ :=
426
458
by { rw neg_eq_iff_neg_eq, simp [eq_comm] }
427
459
428
- @[simp] lemma neg_eg_zero_iff {x : ereal} : - x = 0 ↔ x = 0 :=
429
- by { rw neg_eq_iff_neg_eq, change ((- 0 : ℝ) : ereal) = _ ↔ _, simp [eq_comm] }
460
+ @[simp] lemma neg_eq_zero_iff {x : ereal} : - x = 0 ↔ x = 0 :=
461
+ by { rw neg_eq_iff_neg_eq, simp [eq_comm] }
430
462
431
463
/-- if `-a ≤ b` then `-b ≤ a` on `ereal`. -/
432
464
protected theorem neg_le_of_neg_le : ∀ {a b : ereal} (h : -a ≤ b), -b ≤ a
@@ -448,8 +480,6 @@ by rwa [←neg_neg b, ereal.neg_le, neg_neg]
448
480
@[simp] lemma neg_le_neg_iff {a b : ereal} : - a ≤ - b ↔ b ≤ a :=
449
481
by conv_lhs { rw [ereal.neg_le, neg_neg] }
450
482
451
- @[simp, norm_cast] lemma coe_neg (x : ℝ) : ((- x : ℝ) : ereal) = - (x : ereal) := rfl
452
-
453
483
/-- Negation as an order reversing isomorphism on `ereal`. -/
454
484
def neg_order_iso : ereal ≃o erealᵒᵈ :=
455
485
{ to_fun := λ x, order_dual.to_dual (-x),
@@ -468,19 +498,13 @@ end
468
498
lemma neg_lt_iff_neg_lt {a b : ereal} : -a < b ↔ -b < a :=
469
499
⟨λ h, ereal.neg_lt_of_neg_lt h, λ h, ereal.neg_lt_of_neg_lt h⟩
470
500
471
- /-! ### Subtraction -/
501
+ /-!
502
+ ### Subtraction
472
503
473
- /-- Subtraction on `ereal`, defined by `x - y = x + (-y)`. Since addition is badly behaved at some
504
+ Subtraction on `ereal` is defined by `x - y = x + (-y)`. Since addition is badly behaved at some
474
505
points, so is subtraction. There is no standard algebraic typeclass involving subtraction that is
475
- registered on `ereal`, beyond `sub_neg_zero_monoid`, because of this bad behavior. -/
476
- protected noncomputable def sub (x y : ereal) : ereal := x + (-y)
477
-
478
- noncomputable instance : has_sub ereal := ⟨ereal.sub⟩
479
-
480
- noncomputable instance : sub_neg_zero_monoid ereal :=
481
- { neg_zero := by { change ((-0 : ℝ) : ereal) = 0 , simp },
482
- ..(infer_instance : add_monoid ereal),
483
- ..ereal.has_neg }
506
+ registered on `ereal`, beyond `sub_neg_zero_monoid`, because of this bad behavior.
507
+ -/
484
508
485
509
@[simp] lemma top_sub (x : ereal) : ⊤ - x = ⊤ := top_add x
486
510
@[simp] lemma sub_bot (x : ereal) : x - ⊥ = ⊤ := add_top x
@@ -489,8 +513,6 @@ noncomputable instance : sub_neg_zero_monoid ereal :=
489
513
@[simp] lemma bot_sub_coe (x : ℝ) : (⊥ : ereal) - x = ⊥ := rfl
490
514
@[simp] lemma coe_sub_bot (x : ℝ) : (x : ereal) - ⊤ = ⊥ := rfl
491
515
492
- @[simp] lemma zero_sub (x : ereal) : 0 - x = - x := by { change 0 + (-x) = - x, simp }
493
-
494
516
lemma sub_le_sub {x y z t : ereal} (h : x ≤ y) (h' : t ≤ z) : x - z ≤ y - t :=
495
517
add_le_add h (neg_le_neg_iff.2 h')
496
518
525
547
526
548
/-! ### Multiplication -/
527
549
528
- @[simp] lemma coe_one : ((1 : ℝ) : ereal) = 1 := rfl
529
-
530
- @[simp, norm_cast] lemma coe_mul (x y : ℝ) : ((x * y : ℝ) : ereal) = (x : ereal) * (y : ereal) :=
531
- eq.trans (with_bot.coe_eq_coe.mpr with_bot.coe_mul) with_top.coe_mul
532
-
533
550
@[simp] lemma mul_top (x : ereal) (h : x ≠ 0 ) : x * ⊤ = ⊤ := with_top.mul_top h
534
551
@[simp] lemma top_mul (x : ereal) (h : x ≠ 0 ) : ⊤ * x = ⊤ := with_top.top_mul h
535
552
0 commit comments