l3lab/ntp-mathlib huggingface dataset:
theorem range_coe_eq_Ioo : range Real.toEReal = Ioo ⊥ ⊤ := by
  ext x
  induction x using EReal.rec <;> 

Proof state:
case h.h_top
⊢ ⊤ ∈ range Real.toEReal ↔ ⊤ ∈ Ioo ⊥ ⊤

Next tactic:
simp
theorem toReal_le_toReal {x y : EReal} (h : x ≤ y) (hx : x ≠ ⊥) (hy : y ≠ ⊤) :
    x.toReal ≤ y.toReal := by
  

Proof state:
x y : EReal
h : x ≤ y
hx : x ≠ ⊥
hy : y ≠ ⊤
⊢ toReal x ≤ toReal y

Next tactic:
lift x to ℝ using ⟨ne_top_of_le_ne_top hy h, hx⟩
theorem toReal_le_toReal {x y : EReal} (h : x ≤ y) (hx : x ≠ ⊥) (hy : y ≠ ⊤) :
    x.toReal ≤ y.toReal := by
  lift x to ℝ using ⟨ne_top_of_le_ne_top hy h, hx⟩
  

Proof state:
case intro
y : EReal
hy : y ≠ ⊤
x : ℝ
h : ↑x ≤ y
hx : ↑x ≠ ⊥
⊢ toReal ↑x ≤ toReal y

Next tactic:
lift y to ℝ using ⟨hy, ne_bot_of_le_ne_bot hx h⟩
theorem toReal_le_toReal {x y : EReal} (h : x ≤ y) (hx : x ≠ ⊥) (hy : y ≠ ⊤) :
    x.toReal ≤ y.toReal := by
  lift x to ℝ using ⟨ne_top_of_le_ne_top hy h, hx⟩
  lift y to ℝ using ⟨hy, ne_bot_of_le_ne_bot hx h⟩
  

Proof state:
case intro.intro
x : ℝ
hx : ↑x ≠ ⊥
y : ℝ
hy : ↑y ≠ ⊤
h : ↑x ≤ ↑y
⊢ toReal ↑x ≤ toReal ↑y

Next tactic:
simpa using h
theorem coe_toReal {x : EReal} (hx : x ≠ ⊤) (h'x : x ≠ ⊥) : (x.toReal : EReal) = x := by
  

Proof state:
x : EReal
hx : x ≠ ⊤
h'x : x ≠ ⊥
⊢ ↑(toReal x) = x

Next tactic:
lift x to ℝ using ⟨hx, h'x⟩
theorem coe_toReal {x : EReal} (hx : x ≠ ⊤) (h'x : x ≠ ⊥) : (x.toReal : EReal) = x := by
  lift x to ℝ using ⟨hx, h'x⟩
  

Proof state:
case intro
x : ℝ
hx : ↑x ≠ ⊤
h'x : ↑x ≠ ⊥
⊢ ↑(toReal ↑x) = ↑x

Next tactic:
rfl
theorem le_coe_toReal {x : EReal} (h : x ≠ ⊤) : x ≤ x.toReal := by
  

Proof state:
x : EReal
h : x ≠ ⊤
⊢ x ≤ ↑(toReal x)

Next tactic:
by_cases h' : x = ⊥
theorem le_coe_toReal {x : EReal} (h : x ≠ ⊤) : x ≤ x.toReal := by
  by_cases h' : x = ⊥
  · 

Proof state:
case pos
x : EReal
h : x ≠ ⊤
h' : x = ⊥
⊢ x ≤ ↑(toReal x)

Next tactic:
simp only [h', bot_le]
theorem le_coe_toReal {x : EReal} (h : x ≠ ⊤) : x ≤ x.toReal := by
  by_cases h' : x = ⊥
  · simp only [h', bot_le]
  · 

Proof state:
case neg
x : EReal
h : x ≠ ⊤
h' : ¬x = ⊥
⊢ x ≤ ↑(toReal x)

Next tactic:
simp only [le_refl, coe_toReal h h']
theorem coe_toReal_le {x : EReal} (h : x ≠ ⊥) : ↑x.toReal ≤ x := by
  

Proof state:
x : EReal
h : x ≠ ⊥
⊢ ↑(toReal x) ≤ x

Next tactic:
by_cases h' : x = ⊤
theorem coe_toReal_le {x : EReal} (h : x ≠ ⊥) : ↑x.toReal ≤ x := by
  by_cases h' : x = ⊤
  · 

Proof state:
case pos
x : EReal
h : x ≠ ⊥
h' : x = ⊤
⊢ ↑(toReal x) ≤ x

Next tactic:
simp only [h', le_top]
theorem coe_toReal_le {x : EReal} (h : x ≠ ⊥) : ↑x.toReal ≤ x := by
  by_cases h' : x = ⊤
  · simp only [h', le_top]
  · 

Proof state:
case neg
x : EReal
h : x ≠ ⊥
h' : ¬x = ⊤
⊢ ↑(toReal x) ≤ x

Next tactic:
simp only [le_refl, coe_toReal h' h]
theorem eq_top_iff_forall_lt (x : EReal) : x = ⊤ ↔ ∀ y : ℝ, (y : EReal) < x := by
  

Proof state:
x : EReal
⊢ x = ⊤ ↔ ∀ (y : ℝ), ↑y < x

Next tactic:
constructor
theorem eq_top_iff_forall_lt (x : EReal) : x = ⊤ ↔ ∀ y : ℝ, (y : EReal) < x := by
  constructor
  · 

Proof state:
case mp
x : EReal
⊢ x = ⊤ → ∀ (y : ℝ), ↑y < x

Next tactic:
rintro rfl
theorem eq_top_iff_forall_lt (x : EReal) : x = ⊤ ↔ ∀ y : ℝ, (y : EReal) < x := by
  constructor
  · rintro rfl
    

Proof state:
case mp
⊢ ∀ (y : ℝ), ↑y < ⊤

Next tactic:
exact EReal.coe_lt_top
theorem eq_top_iff_forall_lt (x : EReal) : x = ⊤ ↔ ∀ y : ℝ, (y : EReal) < x := by
  constructor
  · rintro rfl
    exact EReal.coe_lt_top
  · 

Proof state:
case mpr
x : EReal
⊢ (∀ (y : ℝ), ↑y < x) → x = ⊤

Next tactic:
contrapose!
theorem eq_top_iff_forall_lt (x : EReal) : x = ⊤ ↔ ∀ y : ℝ, (y : EReal) < x := by
  constructor
  · rintro rfl
    exact EReal.coe_lt_top
  · contrapose!
    

Proof state:
case mpr
x : EReal
⊢ x ≠ ⊤ → ∃ y, x ≤ ↑y

Next tactic:
intro h
theorem eq_top_iff_forall_lt (x : EReal) : x = ⊤ ↔ ∀ y : ℝ, (y : EReal) < x := by
  constructor
  · rintro rfl
    exact EReal.coe_lt_top
  · contrapose!
    intro h
    

Proof state:
case mpr
x : EReal
h : x ≠ ⊤
⊢ ∃ y, x ≤ ↑y

Next tactic:
exact ⟨x.toReal, le_coe_toReal h⟩
theorem eq_bot_iff_forall_lt (x : EReal) : x = ⊥ ↔ ∀ y : ℝ, x < (y : EReal) := by
  

Proof state:
x : EReal
⊢ x = ⊥ ↔ ∀ (y : ℝ), x < ↑y

Next tactic:
constructor
theorem eq_bot_iff_forall_lt (x : EReal) : x = ⊥ ↔ ∀ y : ℝ, x < (y : EReal) := by
  constructor
  · 

Proof state:
case mp
x : EReal
⊢ x = ⊥ → ∀ (y : ℝ), x < ↑y

Next tactic:
rintro rfl
theorem eq_bot_iff_forall_lt (x : EReal) : x = ⊥ ↔ ∀ y : ℝ, x < (y : EReal) := by
  constructor
  · rintro rfl
    

Proof state:
case mp
⊢ ∀ (y : ℝ), ⊥ < ↑y

Next tactic:
exact bot_lt_coe
theorem eq_bot_iff_forall_lt (x : EReal) : x = ⊥ ↔ ∀ y : ℝ, x < (y : EReal) := by
  constructor
  · rintro rfl
    exact bot_lt_coe
  · 

Proof state:
case mpr
x : EReal
⊢ (∀ (y : ℝ), x < ↑y) → x = ⊥

Next tactic:
contrapose!
theorem eq_bot_iff_forall_lt (x : EReal) : x = ⊥ ↔ ∀ y : ℝ, x < (y : EReal) := by
  constructor
  · rintro rfl
    exact bot_lt_coe
  · contrapose!
    

Proof state:
case mpr
x : EReal
⊢ x ≠ ⊥ → ∃ y, ↑y ≤ x

Next tactic:
intro h
theorem eq_bot_iff_forall_lt (x : EReal) : x = ⊥ ↔ ∀ y : ℝ, x < (y : EReal) := by
  constructor
  · rintro rfl
    exact bot_lt_coe
  · contrapose!
    intro h
    

Proof state:
case mpr
x : EReal
h : x ≠ ⊥
⊢ ∃ y, ↑y ≤ x

Next tactic:
exact ⟨x.toReal, coe_toReal_le h⟩
@[simp, norm_cast]
theorem coe_ennreal_eq_zero {x : ℝ≥0∞} : (x : EReal) = 0 ↔ x = 0 := by
  

Proof state:
x : ℝ≥0∞
⊢ ↑x = 0 ↔ x = 0

Next tactic:
rw [← coe_ennreal_eq_coe_ennreal_iff, coe_ennreal_zero]
@[simp, norm_cast]
theorem coe_ennreal_eq_one {x : ℝ≥0∞} : (x : EReal) = 1 ↔ x = 1 := by
  

Proof state:
x : ℝ≥0∞
⊢ ↑x = 1 ↔ x = 1

Next tactic:
rw [← coe_ennreal_eq_coe_ennreal_iff, coe_ennreal_one]
@[simp, norm_cast]
theorem coe_ennreal_pos {x : ℝ≥0∞} : (0 : EReal) < x ↔ 0 < x := by
  

Proof state:
x : ℝ≥0∞
⊢ 0 < ↑x ↔ 0 < x

Next tactic:
rw [← coe_ennreal_zero, coe_ennreal_lt_coe_ennreal_iff]
@[simp, norm_cast]
theorem coe_ennreal_add (x y : ENNReal) : ((x + y : ℝ≥0∞) : EReal) = x + y := by
  

Proof state:
x y : ℝ≥0∞
⊢ ↑(x + y) = ↑x + ↑y

Next tactic:
cases x
@[simp, norm_cast]
theorem coe_ennreal_add (x y : ENNReal) : ((x + y : ℝ≥0∞) : EReal) = x + y := by
  cases x <;> 

Proof state:
case none
y : ℝ≥0∞
⊢ ↑(none + y) = ↑none + ↑y

Next tactic:
cases y
@[simp, norm_cast]
theorem coe_ennreal_add (x y : ENNReal) : ((x + y : ℝ≥0∞) : EReal) = x + y := by
  cases x <;> 

Proof state:
case some
y : ℝ≥0∞
val✝ : ℝ≥0
⊢ ↑(some val✝ + y) = ↑(some val✝) + ↑y

Next tactic:
cases y
@[simp, norm_cast]
theorem coe_ennreal_add (x y : ENNReal) : ((x + y : ℝ≥0∞) : EReal) = x + y := by
  cases x <;> cases y <;> 

Proof state:
case none.none
⊢ ↑(none + none) = ↑none + ↑none

Next tactic:
rfl
@[simp, norm_cast]
theorem coe_ennreal_add (x y : ENNReal) : ((x + y : ℝ≥0∞) : EReal) = x + y := by
  cases x <;> cases y <;> 

Proof state:
case none.some
val✝ : ℝ≥0
⊢ ↑(none + some val✝) = ↑none + ↑(some val✝)

Next tactic:
rfl
@[simp, norm_cast]
theorem coe_ennreal_add (x y : ENNReal) : ((x + y : ℝ≥0∞) : EReal) = x + y := by
  cases x <;> cases y <;> 

Proof state:
case some.none
val✝ : ℝ≥0
⊢ ↑(some val✝ + none) = ↑(some val✝) + ↑none

Next tactic:
rfl
@[simp, norm_cast]
theorem coe_ennreal_add (x y : ENNReal) : ((x + y : ℝ≥0∞) : EReal) = x + y := by
  cases x <;> cases y <;> 

Proof state:
case some.some
val✝¹ val✝ : ℝ≥0
⊢ ↑(some val✝¹ + some val✝) = ↑(some val✝¹) + ↑(some val✝)

Next tactic:
rfl
private theorem coe_ennreal_top_mul (x : ℝ≥0) : ((⊤ * x : ℝ≥0∞) : EReal) = ⊤ * x := by
  

Proof state:
x : ℝ≥0
⊢ ↑(⊤ * ↑x) = ⊤ * ↑↑x

Next tactic:
rcases eq_or_ne x 0 with (rfl | h0)
private theorem coe_ennreal_top_mul (x : ℝ≥0) : ((⊤ * x : ℝ≥0∞) : EReal) = ⊤ * x := by
  rcases eq_or_ne x 0 with (rfl | h0)
  · 

Proof state:
case inl
⊢ ↑(⊤ * ↑0) = ⊤ * ↑↑0

Next tactic:
simp
private theorem coe_ennreal_top_mul (x : ℝ≥0) : ((⊤ * x : ℝ≥0∞) : EReal) = ⊤ * x := by
  rcases eq_or_ne x 0 with (rfl | h0)
  · simp
  · 

Proof state:
case inr
x : ℝ≥0
h0 : x ≠ 0
⊢ ↑(⊤ * ↑x) = ⊤ * ↑↑x

Next tactic:
rw [ENNReal.top_mul (ENNReal.coe_ne_zero.2 h0)]
private theorem coe_ennreal_top_mul (x : ℝ≥0) : ((⊤ * x : ℝ≥0∞) : EReal) = ⊤ * x := by
  rcases eq_or_ne x 0 with (rfl | h0)
  · simp
  · rw [ENNReal.top_mul (ENNReal.coe_ne_zero.2 h0)]
    

Proof state:
case inr
x : ℝ≥0
h0 : x ≠ 0
⊢ ↑⊤ = ⊤ * ↑↑x

Next tactic:
exact Eq.symm <| if_pos <| NNReal.coe_pos.2 h0.bot_lt
@[simp, norm_cast]
theorem coe_ennreal_mul : ∀ x y : ℝ≥0∞, ((x * y : ℝ≥0∞) : EReal) = (x : EReal) * y
  | ⊤, ⊤ => rfl
  | ⊤, (y : ℝ≥0) => coe_ennreal_top_mul y
  | (x : ℝ≥0), ⊤ => by
    

Proof state:
x : ℝ≥0
⊢ ↑(↑x * ⊤) = ↑↑x * ↑⊤

Next tactic:
rw [mul_comm, coe_ennreal_top_mul, EReal.mul_comm, coe_ennreal_top]
@[simp, norm_cast]
theorem coe_ennreal_mul : ∀ x y : ℝ≥0∞, ((x * y : ℝ≥0∞) : EReal) = (x : EReal) * y
  | ⊤, ⊤ => rfl
  | ⊤, (y : ℝ≥0) => coe_ennreal_top_mul y
  | (x : ℝ≥0), ⊤ => by
    rw [mul_comm, coe_ennreal_top_mul, EReal.mul_comm, coe_ennreal_top]
  | (x : ℝ≥0), (y : ℝ≥0) => by
    

Proof state:
x y : ℝ≥0
⊢ ↑(↑x * ↑y) = ↑↑x * ↑↑y

Next tactic:
simp only [← ENNReal.coe_mul, coe_nnreal_eq_coe_real, NNReal.coe_mul, EReal.coe_mul]
theorem exists_rat_btwn_of_lt :
    ∀ {a b : EReal}, a < b → ∃ x : ℚ, a < (x : ℝ) ∧ ((x : ℝ) : EReal) < b
  | ⊤, b, h => (not_top_lt h).elim
  | (a : ℝ), ⊥, h => (lt_irrefl _ ((bot_lt_coe a).trans h)).elim
  | (a : ℝ), (b : ℝ), h => by 

Proof state:
a b : ℝ
h : ↑a < ↑b
⊢ ∃ x, ↑a < ↑↑x ∧ ↑↑x < ↑b

Next tactic:
simp [exists_rat_btwn (EReal.coe_lt_coe_iff.1 h)]
theorem exists_rat_btwn_of_lt :
    ∀ {a b : EReal}, a < b → ∃ x : ℚ, a < (x : ℝ) ∧ ((x : ℝ) : EReal) < b
  | ⊤, b, h => (not_top_lt h).elim
  | (a : ℝ), ⊥, h => (lt_irrefl _ ((bot_lt_coe a).trans h)).elim
  | (a : ℝ), (b : ℝ), h => by simp [exists_rat_btwn (EReal.coe_lt_coe_iff.1 h)]
  | (a : ℝ), ⊤, _ =>
    let ⟨b, hab⟩ := exists_rat_gt a
    ⟨b, by 

Proof state:
a : ℝ
x✝ : ↑a < ⊤
b : ℚ
hab : a < ↑b
⊢ ↑a < ↑↑b

Next tactic:
simpa using hab
theorem exists_rat_btwn_of_lt :
    ∀ {a b : EReal}, a < b → ∃ x : ℚ, a < (x : ℝ) ∧ ((x : ℝ) : EReal) < b
  | ⊤, b, h => (not_top_lt h).elim
  | (a : ℝ), ⊥, h => (lt_irrefl _ ((bot_lt_coe a).trans h)).elim
  | (a : ℝ), (b : ℝ), h => by simp [exists_rat_btwn (EReal.coe_lt_coe_iff.1 h)]
  | (a : ℝ), ⊤, _ =>
    let ⟨b, hab⟩ := exists_rat_gt a
    ⟨b, by simpa using hab, coe_lt_top _⟩
  | ⊥, ⊥, h => (lt_irrefl _ h).elim
  | ⊥, (a : ℝ), _ =>
    let ⟨b, hab⟩ := exists_rat_lt a
    ⟨b, bot_lt_coe _, by 

Proof state:
a : ℝ
x✝ : ⊥ < ↑a
b : ℚ
hab : ↑b < a
⊢ ↑↑b < ↑a

Next tactic:
simpa using hab
/-- The set of numbers in `EReal` that are not equal to `±∞` is equivalent to `ℝ`. -/
def neTopBotEquivReal : ({⊥, ⊤}ᶜ : Set EReal) ≃ ℝ where
  toFun x := EReal.toReal x
  invFun x := ⟨x, by 

Proof state:
x : ℝ
⊢ ↑x ∈ {⊥, ⊤}ᶜ

Next tactic:
simp
/-- The set of numbers in `EReal` that are not equal to `±∞` is equivalent to `ℝ`. -/
def neTopBotEquivReal : ({⊥, ⊤}ᶜ : Set EReal) ≃ ℝ where
  toFun x := EReal.toReal x
  invFun x := ⟨x, by simp⟩
  left_inv := fun ⟨x, hx⟩ => by
    

Proof state:
x✝ : ↑{⊥, ⊤}ᶜ
x : EReal
hx : x ∈ {⊥, ⊤}ᶜ
⊢ (fun x => { val := ↑x, property := (_ : ↑x ∈ {⊥, ⊤}ᶜ) }) ((fun x => toReal ↑x) { val := x, property := hx }) =
    { val := x, property := hx }

Next tactic:
lift x to ℝ
/-- The set of numbers in `EReal` that are not equal to `±∞` is equivalent to `ℝ`. -/
def neTopBotEquivReal : ({⊥, ⊤}ᶜ : Set EReal) ≃ ℝ where
  toFun x := EReal.toReal x
  invFun x := ⟨x, by simp⟩
  left_inv := fun ⟨x, hx⟩ => by
    lift x to ℝ
    · 

Proof state:
x✝ : ↑{⊥, ⊤}ᶜ
x : EReal
hx : x ∈ {⊥, ⊤}ᶜ
⊢ x ≠ ⊤ ∧ x ≠ ⊥

Next tactic:
simpa [not_or, and_comm] using hx
/-- The set of numbers in `EReal` that are not equal to `±∞` is equivalent to `ℝ`. -/
def neTopBotEquivReal : ({⊥, ⊤}ᶜ : Set EReal) ≃ ℝ where
  toFun x := EReal.toReal x
  invFun x := ⟨x, by simp⟩
  left_inv := fun ⟨x, hx⟩ => by
    lift x to ℝ
    · simpa [not_or, and_comm] using hx
    · 

Proof state:
case intro
x✝ : ↑{⊥, ⊤}ᶜ
x : ℝ
hx : ↑x ∈ {⊥, ⊤}ᶜ
⊢ (fun x => { val := ↑x, property := (_ : ↑x ∈ {⊥, ⊤}ᶜ) }) ((fun x => toReal ↑x) { val := ↑x, property := hx }) =
    { val := ↑x, property := hx }

Next tactic:
simp
/-- The set of numbers in `EReal` that are not equal to `±∞` is equivalent to `ℝ`. -/
def neTopBotEquivReal : ({⊥, ⊤}ᶜ : Set EReal) ≃ ℝ where
  toFun x := EReal.toReal x
  invFun x := ⟨x, by simp⟩
  left_inv := fun ⟨x, hx⟩ => by
    lift x to ℝ
    · simpa [not_or, and_comm] using hx
    · simp
  right_inv x := by 

Proof state:
x : ℝ
⊢ (fun x => toReal ↑x) ((fun x => { val := ↑x, property := (_ : ↑x ∈ {⊥, ⊤}ᶜ) }) x) = x

Next tactic:
simp
@[simp]
theorem bot_lt_add_iff {x y : EReal} : ⊥ < x + y ↔ ⊥ < x ∧ ⊥ < y := by
  

Proof state:
x y : EReal
⊢ ⊥ < x + y ↔ ⊥ < x ∧ ⊥ < y

Next tactic:
simp [bot_lt_iff_ne_bot, not_or]
theorem toReal_add {x y : EReal} (hx : x ≠ ⊤) (h'x : x ≠ ⊥) (hy : y ≠ ⊤) (h'y : y ≠ ⊥) :
    toReal (x + y) = toReal x + toReal y := by
  

Proof state:
x y : EReal
hx : x ≠ ⊤
h'x : x ≠ ⊥
hy : y ≠ ⊤
h'y : y ≠ ⊥
⊢ toReal (x + y) = toReal x + toReal y

Next tactic:
lift x to ℝ using ⟨hx, h'x⟩
theorem toReal_add {x y : EReal} (hx : x ≠ ⊤) (h'x : x ≠ ⊥) (hy : y ≠ ⊤) (h'y : y ≠ ⊥) :
    toReal (x + y) = toReal x + toReal y := by
  lift x to ℝ using ⟨hx, h'x⟩
  

Proof state:
case intro
y : EReal
hy : y ≠ ⊤
h'y : y ≠ ⊥
x : ℝ
hx : ↑x ≠ ⊤
h'x : ↑x ≠ ⊥
⊢ toReal (↑x + y) = toReal ↑x + toReal y

Next tactic:
lift y to ℝ using ⟨hy, h'y⟩
theorem toReal_add {x y : EReal} (hx : x ≠ ⊤) (h'x : x ≠ ⊥) (hy : y ≠ ⊤) (h'y : y ≠ ⊥) :
    toReal (x + y) = toReal x + toReal y := by
  lift x to ℝ using ⟨hx, h'x⟩
  lift y to ℝ using ⟨hy, h'y⟩
  

Proof state:
case intro.intro
x : ℝ
hx : ↑x ≠ ⊤
h'x : ↑x ≠ ⊥
y : ℝ
hy : ↑y ≠ ⊤
h'y : ↑y ≠ ⊥
⊢ toReal (↑x + ↑y) = toReal ↑x + toReal ↑y

Next tactic:
rfl
theorem addLECancellable_coe (x : ℝ) : AddLECancellable (x : EReal)
  | _, ⊤, _ => le_top
  | ⊥, _, _ => bot_le
  | ⊤, (z : ℝ), h => by 

Proof state:
x z : ℝ
h : ↑x + ⊤ ≤ ↑x + ↑z
⊢ ⊤ ≤ ↑z

Next tactic:
simp only [coe_add_top, ← coe_add, top_le_iff, coe_ne_top] at h
theorem addLECancellable_coe (x : ℝ) : AddLECancellable (x : EReal)
  | _, ⊤, _ => le_top
  | ⊥, _, _ => bot_le
  | ⊤, (z : ℝ), h => by simp only [coe_add_top, ← coe_add, top_le_iff, coe_ne_top] at h
  | _, ⊥, h => by 

Proof state:
x : ℝ
x✝ : EReal
h : ↑x + x✝ ≤ ↑x + ⊥
⊢ x✝ ≤ ⊥

Next tactic:
simpa using h
theorem addLECancellable_coe (x : ℝ) : AddLECancellable (x : EReal)
  | _, ⊤, _ => le_top
  | ⊥, _, _ => bot_le
  | ⊤, (z : ℝ), h => by simp only [coe_add_top, ← coe_add, top_le_iff, coe_ne_top] at h
  | _, ⊥, h => by simpa using h
  | (y : ℝ), (z : ℝ), h => by
    

Proof state:
x y z : ℝ
h : ↑x + ↑y ≤ ↑x + ↑z
⊢ ↑y ≤ ↑z

Next tactic:
simpa only [← coe_add, EReal.coe_le_coe_iff, add_le_add_iff_left] using h
theorem add_lt_add_left_coe {x y : EReal} (h : x < y) (z : ℝ) : (z : EReal) + x < z + y := by
  

Proof state:
x y : EReal
h : x < y
z : ℝ
⊢ ↑z + x < ↑z + y

Next tactic:
simpa [add_comm] using add_lt_add_right_coe h z
theorem add_lt_add {x y z t : EReal} (h1 : x < y) (h2 : z < t) : x + z < y + t := by
  

Proof state:
x y z t : EReal
h1 : x < y
h2 : z < t
⊢ x + z < y + t

Next tactic:
rcases eq_or_ne x ⊥ with (rfl | hx)
theorem add_lt_add {x y z t : EReal} (h1 : x < y) (h2 : z < t) : x + z < y + t := by
  rcases eq_or_ne x ⊥ with (rfl | hx)
  · 

Proof state:
case inl
y z t : EReal
h2 : z < t
h1 : ⊥ < y
⊢ ⊥ + z < y + t

Next tactic:
simp [h1, bot_le.trans_lt h2]
theorem add_lt_add {x y z t : EReal} (h1 : x < y) (h2 : z < t) : x + z < y + t := by
  rcases eq_or_ne x ⊥ with (rfl | hx)
  · simp [h1, bot_le.trans_lt h2]
  · 

Proof state:
case inr
x y z t : EReal
h1 : x < y
h2 : z < t
hx : x ≠ ⊥
⊢ x + z < y + t

Next tactic:
lift x to ℝ using ⟨h1.ne_top, hx⟩
theorem add_lt_add {x y z t : EReal} (h1 : x < y) (h2 : z < t) : x + z < y + t := by
  rcases eq_or_ne x ⊥ with (rfl | hx)
  · simp [h1, bot_le.trans_lt h2]
  · lift x to ℝ using ⟨h1.ne_top, hx⟩
    

Proof state:
case inr.intro
y z t : EReal
h2 : z < t
x : ℝ
h1 : ↑x < y
hx : ↑x ≠ ⊥
⊢ ↑x + z < y + t

Next tactic:
calc (x : EReal) + z < x + t := add_lt_add_left_coe h2 _
    _ ≤ y + t := add_le_add_right h1.le _
theorem add_lt_add_of_lt_of_le' {x y z t : EReal} (h : x < y) (h' : z ≤ t) (hbot : t ≠ ⊥)
    (htop : t = ⊤ → z = ⊤ → x = ⊥) : x + z < y + t := by
  

Proof state:
x y z t : EReal
h : x < y
h' : z ≤ t
hbot : t ≠ ⊥
htop : t = ⊤ → z = ⊤ → x = ⊥
⊢ x + z < y + t

Next tactic:
rcases h'.eq_or_lt with (rfl | hlt)
theorem add_lt_add_of_lt_of_le' {x y z t : EReal} (h : x < y) (h' : z ≤ t) (hbot : t ≠ ⊥)
    (htop : t = ⊤ → z = ⊤ → x = ⊥) : x + z < y + t := by
  rcases h'.eq_or_lt with (rfl | hlt)
  · 

Proof state:
case inl
x y z : EReal
h : x < y
h' : z ≤ z
hbot : z ≠ ⊥
htop : z = ⊤ → z = ⊤ → x = ⊥
⊢ x + z < y + z

Next tactic:
rcases eq_or_ne z ⊤ with (rfl | hz)
theorem add_lt_add_of_lt_of_le' {x y z t : EReal} (h : x < y) (h' : z ≤ t) (hbot : t ≠ ⊥)
    (htop : t = ⊤ → z = ⊤ → x = ⊥) : x + z < y + t := by
  rcases h'.eq_or_lt with (rfl | hlt)
  · rcases eq_or_ne z ⊤ with (rfl | hz)
    · 

Proof state:
case inl.inl
x y : EReal
h : x < y
h' : ⊤ ≤ ⊤
hbot : ⊤ ≠ ⊥
htop : ⊤ = ⊤ → ⊤ = ⊤ → x = ⊥
⊢ x + ⊤ < y + ⊤

Next tactic:
obtain rfl := htop rfl rfl
theorem add_lt_add_of_lt_of_le' {x y z t : EReal} (h : x < y) (h' : z ≤ t) (hbot : t ≠ ⊥)
    (htop : t = ⊤ → z = ⊤ → x = ⊥) : x + z < y + t := by
  rcases h'.eq_or_lt with (rfl | hlt)
  · rcases eq_or_ne z ⊤ with (rfl | hz)
    · obtain rfl := htop rfl rfl
      

Proof state:
case inl.inl
y : EReal
h' : ⊤ ≤ ⊤
hbot : ⊤ ≠ ⊥
h : ⊥ < y
htop : ⊤ = ⊤ → ⊤ = ⊤ → ⊥ = ⊥
⊢ ⊥ + ⊤ < y + ⊤

Next tactic:
simpa
theorem add_lt_add_of_lt_of_le' {x y z t : EReal} (h : x < y) (h' : z ≤ t) (hbot : t ≠ ⊥)
    (htop : t = ⊤ → z = ⊤ → x = ⊥) : x + z < y + t := by
  rcases h'.eq_or_lt with (rfl | hlt)
  · rcases eq_or_ne z ⊤ with (rfl | hz)
    · obtain rfl := htop rfl rfl
      simpa
    

Proof state:
case inl.inr
x y z : EReal
h : x < y
h' : z ≤ z
hbot : z ≠ ⊥
htop : z = ⊤ → z = ⊤ → x = ⊥
hz : z ≠ ⊤
⊢ x + z < y + z

Next tactic:
lift z to ℝ using ⟨hz, hbot⟩
theorem add_lt_add_of_lt_of_le' {x y z t : EReal} (h : x < y) (h' : z ≤ t) (hbot : t ≠ ⊥)
    (htop : t = ⊤ → z = ⊤ → x = ⊥) : x + z < y + t := by
  rcases h'.eq_or_lt with (rfl | hlt)
  · rcases eq_or_ne z ⊤ with (rfl | hz)
    · obtain rfl := htop rfl rfl
      simpa
    lift z to ℝ using ⟨hz, hbot⟩
    

Proof state:
case inl.inr.intro
x y : EReal
h : x < y
z : ℝ
h' : ↑z ≤ ↑z
hbot : ↑z ≠ ⊥
htop : ↑z = ⊤ → ↑z = ⊤ → x = ⊥
hz : ↑z ≠ ⊤
⊢ x + ↑z < y + ↑z

Next tactic:
exact add_lt_add_right_coe h z
theorem add_lt_add_of_lt_of_le' {x y z t : EReal} (h : x < y) (h' : z ≤ t) (hbot : t ≠ ⊥)
    (htop : t = ⊤ → z = ⊤ → x = ⊥) : x + z < y + t := by
  rcases h'.eq_or_lt with (rfl | hlt)
  · rcases eq_or_ne z ⊤ with (rfl | hz)
    · obtain rfl := htop rfl rfl
      simpa
    lift z to ℝ using ⟨hz, hbot⟩
    exact add_lt_add_right_coe h z
  · 

Proof state:
case inr
x y z t : EReal
h : x < y
h' : z ≤ t
hbot : t ≠ ⊥
htop : t = ⊤ → z = ⊤ → x = ⊥
hlt : z < t
⊢ x + z < y + t

Next tactic:
exact add_lt_add h hlt
theorem add_lt_top {x y : EReal} (hx : x ≠ ⊤) (hy : y ≠ ⊤) : x + y < ⊤ := by
  

Proof state:
x y : EReal
hx : x ≠ ⊤
hy : y ≠ ⊤
⊢ x + y < ⊤

Next tactic:
rw [← EReal.top_add_top]
theorem add_lt_top {x y : EReal} (hx : x ≠ ⊤) (hy : y ≠ ⊤) : x + y < ⊤ := by
  rw [← EReal.top_add_top]
  

Proof state:
x y : EReal
hx : x ≠ ⊤
hy : y ≠ ⊤
⊢ x + y < ⊤ + ⊤

Next tactic:
exact EReal.add_lt_add hx.lt_top hy.lt_top
/-- We do not have a notion of `LinearOrderedAddCommMonoidWithBot` but we can at least make
the order dual of the extended reals into a `LinearOrderedAddCommMonoidWithTop`. -/
instance : LinearOrderedAddCommMonoidWithTop ERealᵒᵈ where
  le_top := by 

Proof state:
⊢ ∀ (a : ERealᵒᵈ), a ≤ ⊤

Next tactic:
simp
/-- We do not have a notion of `LinearOrderedAddCommMonoidWithBot` but we can at least make
the order dual of the extended reals into a `LinearOrderedAddCommMonoidWithTop`. -/
instance : LinearOrderedAddCommMonoidWithTop ERealᵒᵈ where
  le_top := by simp
  top_add' := by
    

Proof state:
⊢ ∀ (x : ERealᵒᵈ), ⊤ + x = ⊤

Next tactic:
rw [OrderDual.forall]
/-- We do not have a notion of `LinearOrderedAddCommMonoidWithBot` but we can at least make
the order dual of the extended reals into a `LinearOrderedAddCommMonoidWithTop`. -/
instance : LinearOrderedAddCommMonoidWithTop ERealᵒᵈ where
  le_top := by simp
  top_add' := by
    rw [OrderDual.forall]
    

Proof state:
⊢ ∀ (a : EReal), ⊤ + OrderDual.toDual a = ⊤

Next tactic:
intro x
/-- We do not have a notion of `LinearOrderedAddCommMonoidWithBot` but we can at least make
the order dual of the extended reals into a `LinearOrderedAddCommMonoidWithTop`. -/
instance : LinearOrderedAddCommMonoidWithTop ERealᵒᵈ where
  le_top := by simp
  top_add' := by
    rw [OrderDual.forall]
    intro x
    

Proof state:
x : EReal
⊢ ⊤ + OrderDual.toDual x = ⊤

Next tactic:
rw [← OrderDual.toDual_bot, ← toDual_add, bot_add, OrderDual.toDual_bot]
@[simp]
theorem toReal_neg : ∀ {a : EReal}, toReal (-a) = -toReal a
  | ⊤ => by 

Proof state:
⊢ toReal (-⊤) = -toReal ⊤

Next tactic:
simp
@[simp]
theorem toReal_neg : ∀ {a : EReal}, toReal (-a) = -toReal a
  | ⊤ => by simp
  | ⊥ => by 

Proof state:
⊢ toReal (-⊥) = -toReal ⊥

Next tactic:
simp
/-- `-a ≤ b ↔ -b ≤ a` on `EReal`. -/
protected theorem neg_le {a b : EReal} : -a ≤ b ↔ -b ≤ a := by
 

Proof state:
a b : EReal
⊢ -a ≤ b ↔ -b ≤ a

Next tactic:
rw [← neg_le_neg_iff, neg_neg]
/-- `a ≤ -b → b ≤ -a` on ereal -/
theorem le_neg_of_le_neg {a b : EReal} (h : a ≤ -b) : b ≤ -a := by
  

Proof state:
a b : EReal
h : a ≤ -b
⊢ b ≤ -a

Next tactic:
rwa [← neg_neg b, EReal.neg_le, neg_neg]
theorem neg_lt_iff_neg_lt {a b : EReal} : -a < b ↔ -b < a := by
  

Proof state:
a b : EReal
⊢ -a < b ↔ -b < a

Next tactic:
rw [← neg_lt_neg_iff, neg_neg]
theorem sub_lt_sub_of_lt_of_le {x y z t : EReal} (h : x < y) (h' : z ≤ t) (hz : z ≠ ⊥)
    (ht : t ≠ ⊤) : x - t < y - z :=
  add_lt_add_of_lt_of_le h (neg_le_neg_iff.2 h') (by 

Proof state:
x y z t : EReal
h : x < y
h' : z ≤ t
hz : z ≠ ⊥
ht : t ≠ ⊤
⊢ -t ≠ ⊥

Next tactic:
simp [ht]
theorem sub_lt_sub_of_lt_of_le {x y z t : EReal} (h : x < y) (h' : z ≤ t) (hz : z ≠ ⊥)
    (ht : t ≠ ⊤) : x - t < y - z :=
  add_lt_add_of_lt_of_le h (neg_le_neg_iff.2 h') (by simp [ht]) (by 

Proof state:
x y z t : EReal
h : x < y
h' : z ≤ t
hz : z ≠ ⊥
ht : t ≠ ⊤
⊢ -z ≠ ⊤

Next tactic:
simp [hz]
theorem coe_real_ereal_eq_coe_toNNReal_sub_coe_toNNReal (x : ℝ) :
    (x : EReal) = Real.toNNReal x - Real.toNNReal (-x) := by
  

Proof state:
x : ℝ
⊢ ↑x = ↑↑(Real.toNNReal x) - ↑↑(Real.toNNReal (-x))

Next tactic:
rcases le_total 0 x with (h | h)
theorem coe_real_ereal_eq_coe_toNNReal_sub_coe_toNNReal (x : ℝ) :
    (x : EReal) = Real.toNNReal x - Real.toNNReal (-x) := by
  rcases le_total 0 x with (h | h)
  · 

Proof state:
case inl
x : ℝ
h : 0 ≤ x
⊢ ↑x = ↑↑(Real.toNNReal x) - ↑↑(Real.toNNReal (-x))

Next tactic:
lift x to ℝ≥0 using h
theorem coe_real_ereal_eq_coe_toNNReal_sub_coe_toNNReal (x : ℝ) :
    (x : EReal) = Real.toNNReal x - Real.toNNReal (-x) := by
  rcases le_total 0 x with (h | h)
  · lift x to ℝ≥0 using h
    

Proof state:
case inl.intro
x : ℝ≥0
⊢ ↑↑x = ↑↑(Real.toNNReal ↑x) - ↑↑(Real.toNNReal (-↑x))

Next tactic:
rw [Real.toNNReal_of_nonpos (neg_nonpos.mpr x.coe_nonneg), Real.toNNReal_coe, ENNReal.coe_zero,
      coe_ennreal_zero, sub_zero]
theorem coe_real_ereal_eq_coe_toNNReal_sub_coe_toNNReal (x : ℝ) :
    (x : EReal) = Real.toNNReal x - Real.toNNReal (-x) := by
  rcases le_total 0 x with (h | h)
  · lift x to ℝ≥0 using h
    rw [Real.toNNReal_of_nonpos (neg_nonpos.mpr x.coe_nonneg), Real.toNNReal_coe, ENNReal.coe_zero,
      coe_ennreal_zero, sub_zero]
    

Proof state:
case inl.intro
x : ℝ≥0
⊢ ↑↑x = ↑↑x

Next tactic:
rfl
theorem coe_real_ereal_eq_coe_toNNReal_sub_coe_toNNReal (x : ℝ) :
    (x : EReal) = Real.toNNReal x - Real.toNNReal (-x) := by
  rcases le_total 0 x with (h | h)
  · lift x to ℝ≥0 using h
    rw [Real.toNNReal_of_nonpos (neg_nonpos.mpr x.coe_nonneg), Real.toNNReal_coe, ENNReal.coe_zero,
      coe_ennreal_zero, sub_zero]
    rfl
  · 

Proof state:
case inr
x : ℝ
h : x ≤ 0
⊢ ↑x = ↑↑(Real.toNNReal x) - ↑↑(Real.toNNReal (-x))

Next tactic:
rw [Real.toNNReal_of_nonpos h, ENNReal.coe_zero, coe_ennreal_zero, coe_nnreal_eq_coe_real,
      Real.coe_toNNReal, zero_sub, coe_neg, neg_neg]