diff --git a/src/data/real/ennreal.lean b/src/data/real/ennreal.lean index 994e7e8ce337c..6f0d22f562e8e 100644 --- a/src/data/real/ennreal.lean +++ b/src/data/real/ennreal.lean @@ -190,6 +190,17 @@ by rintro (h | h); simp [h]⟩ lemma to_real_eq_zero_iff (x : ℝ≥0∞) : x.to_real = 0 ↔ x = 0 ∨ x = ∞ := by simp [ennreal.to_real, to_nnreal_eq_zero_iff] +lemma to_nnreal_eq_one_iff (x : ℝ≥0∞) : x.to_nnreal = 1 ↔ x = 1 := +begin + refine ⟨λ h, _, congr_arg _⟩, + cases x, + { exact false.elim (zero_ne_one $ ennreal.top_to_nnreal.symm.trans h) }, + { exact congr_arg _ h } +end + +lemma to_real_eq_one_iff (x : ℝ≥0∞) : x.to_real = 1 ↔ x = 1 := +by rw [ennreal.to_real, nnreal.coe_eq_one, ennreal.to_nnreal_eq_one_iff] + @[simp] lemma coe_ne_top : (r : ℝ≥0∞) ≠ ∞ := with_top.coe_ne_top @[simp] lemma top_ne_coe : ∞ ≠ (r : ℝ≥0∞) := with_top.top_ne_coe @[simp] lemma of_real_ne_top {r : ℝ} : ennreal.of_real r ≠ ∞ := by simp [ennreal.of_real] @@ -222,6 +233,29 @@ lemma coe_ne_zero : (r : ℝ≥0∞) ≠ 0 ↔ r ≠ 0 := not_congr coe_eq_coe @[simp, norm_cast] lemma coe_bit1 : (↑(bit1 r) : ℝ≥0∞) = bit1 r := by simp [bit1] lemma coe_two : ((2:ℝ≥0) : ℝ≥0∞) = 2 := by norm_cast +lemma to_nnreal_eq_to_nnreal_iff (x y : ℝ≥0∞) : + x.to_nnreal = y.to_nnreal ↔ x = y ∨ (x = 0 ∧ y = ⊤) ∨ (x = ⊤ ∧ y = 0) := +begin + cases x, + { simp only [@eq_comm ℝ≥0 _ y.to_nnreal, @eq_comm ℝ≥0∞ _ y, to_nnreal_eq_zero_iff, + none_eq_top, top_to_nnreal, top_ne_zero, false_and, eq_self_iff_true, + true_and, false_or, or_comm (y = ⊤)] }, + { cases y; simp } +end + +lemma to_real_eq_to_real_iff (x y : ℝ≥0∞) : + x.to_real = y.to_real ↔ x = y ∨ (x = 0 ∧ y = ⊤) ∨ (x = ⊤ ∧ y = 0) := +by simp only [ennreal.to_real, nnreal.coe_eq, to_nnreal_eq_to_nnreal_iff] + +lemma to_nnreal_eq_to_nnreal_iff' {x y : ℝ≥0∞} (hx : x ≠ ⊤) (hy : y ≠ ⊤) : + x.to_nnreal = y.to_nnreal ↔ x = y := +by simp only [ennreal.to_nnreal_eq_to_nnreal_iff x y, hx, hy, and_false, false_and, or_false] + +lemma to_real_eq_to_real_iff' {x y : ℝ≥0∞} (hx : x ≠ ⊤) (hy : y ≠ ⊤) : + x.to_real = y.to_real ↔ x = y := +by simp only [ennreal.to_real, nnreal.coe_eq, to_nnreal_eq_to_nnreal_iff' hx hy] + + protected lemma zero_lt_one : 0 < (1 : ℝ≥0∞) := canonically_ordered_comm_semiring.zero_lt_one