Skip to content

Commit

Permalink
feat(real/ennreal): basic lemmas about ennreal.to_nnreal and `ennre…
Browse files Browse the repository at this point in the history
…al.to_real` (#16318)

Provides lemmas for when `to_nnreal` or `to_real` equal `1`, and when two instances of `to_nnreal` and `to_real` equal each other.
  • Loading branch information
dtumad committed Sep 26, 2022
1 parent d5e1961 commit a44ce4d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/data/real/ennreal.lean
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit a44ce4d

Please sign in to comment.