l3lab/ntp-mathlib huggingface dataset:
@[simp]
theorem toNNRat_coe_nat (n : ℕ) : toNNRat n = n :=
  ext <| by 

Proof state:
α : Type u_1
p q : ℚ≥0
n : ℕ
⊢ ↑(toNNRat ↑n) = ↑↑n

Next tactic:
simp only [Nat.cast_nonneg, Rat.coe_toNNRat]
@[simp]
theorem toNNRat_coe_nat (n : ℕ) : toNNRat n = n :=
  ext <| by simp only [Nat.cast_nonneg, Rat.coe_toNNRat]; 

Proof state:
α : Type u_1
p q : ℚ≥0
n : ℕ
⊢ ↑n = ↑↑n

Next tactic:
rfl
theorem toNNRat_sum_of_nonneg {s : Finset α} {f : α → ℚ} (hf : ∀ a, a ∈ s → 0 ≤ f a) :
    (∑ a in s, f a).toNNRat = ∑ a in s, (f a).toNNRat := by
  

Proof state:
α : Type u_1
p q : ℚ≥0
s : Finset α
f : α → ℚ
hf : ∀ a ∈ s, 0 ≤ f a
⊢ toNNRat (∑ a in s, f a) = ∑ a in s, toNNRat (f a)

Next tactic:
rw [← coe_inj, coe_sum, Rat.coe_toNNRat _ (Finset.sum_nonneg hf)]
theorem toNNRat_sum_of_nonneg {s : Finset α} {f : α → ℚ} (hf : ∀ a, a ∈ s → 0 ≤ f a) :
    (∑ a in s, f a).toNNRat = ∑ a in s, (f a).toNNRat := by
  rw [← coe_inj, coe_sum, Rat.coe_toNNRat _ (Finset.sum_nonneg hf)]
  

Proof state:
α : Type u_1
p q : ℚ≥0
s : Finset α
f : α → ℚ
hf : ∀ a ∈ s, 0 ≤ f a
⊢ ∑ i in s, f i = ∑ a in s, ↑(toNNRat (f a))

Next tactic:
exact Finset.sum_congr rfl fun x hxs ↦ by rw [Rat.coe_toNNRat _ (hf x hxs)]
theorem toNNRat_sum_of_nonneg {s : Finset α} {f : α → ℚ} (hf : ∀ a, a ∈ s → 0 ≤ f a) :
    (∑ a in s, f a).toNNRat = ∑ a in s, (f a).toNNRat := by
  rw [← coe_inj, coe_sum, Rat.coe_toNNRat _ (Finset.sum_nonneg hf)]
  exact Finset.sum_congr rfl fun x hxs ↦ by 

Proof state:
α : Type u_1
p q : ℚ≥0
s : Finset α
f : α → ℚ
hf : ∀ a ∈ s, 0 ≤ f a
x : α
hxs : x ∈ s
⊢ f x = ↑(toNNRat (f x))

Next tactic:
rw [Rat.coe_toNNRat _ (hf x hxs)]
theorem toNNRat_prod_of_nonneg {s : Finset α} {f : α → ℚ} (hf : ∀ a ∈ s, 0 ≤ f a) :
    (∏ a in s, f a).toNNRat = ∏ a in s, (f a).toNNRat := by
  

Proof state:
α : Type u_1
p q : ℚ≥0
s : Finset α
f : α → ℚ
hf : ∀ a ∈ s, 0 ≤ f a
⊢ toNNRat (∏ a in s, f a) = ∏ a in s, toNNRat (f a)

Next tactic:
rw [← coe_inj, coe_prod, Rat.coe_toNNRat _ (Finset.prod_nonneg hf)]
theorem toNNRat_prod_of_nonneg {s : Finset α} {f : α → ℚ} (hf : ∀ a ∈ s, 0 ≤ f a) :
    (∏ a in s, f a).toNNRat = ∏ a in s, (f a).toNNRat := by
  rw [← coe_inj, coe_prod, Rat.coe_toNNRat _ (Finset.prod_nonneg hf)]
  

Proof state:
α : Type u_1
p q : ℚ≥0
s : Finset α
f : α → ℚ
hf : ∀ a ∈ s, 0 ≤ f a
⊢ ∏ i in s, f i = ∏ a in s, ↑(toNNRat (f a))

Next tactic:
exact Finset.prod_congr rfl fun x hxs ↦ by rw [Rat.coe_toNNRat _ (hf x hxs)]
theorem toNNRat_prod_of_nonneg {s : Finset α} {f : α → ℚ} (hf : ∀ a ∈ s, 0 ≤ f a) :
    (∏ a in s, f a).toNNRat = ∏ a in s, (f a).toNNRat := by
  rw [← coe_inj, coe_prod, Rat.coe_toNNRat _ (Finset.prod_nonneg hf)]
  exact Finset.prod_congr rfl fun x hxs ↦ by 

Proof state:
α : Type u_1
p q : ℚ≥0
s : Finset α
f : α → ℚ
hf : ∀ a ∈ s, 0 ≤ f a
x : α
hxs : x ∈ s
⊢ f x = ↑(toNNRat (f x))

Next tactic:
rw [Rat.coe_toNNRat _ (hf x hxs)]
@[simp]
theorem toNNRat_pos : 0 < toNNRat q ↔ 0 < q := by 

Proof state:
p q : ℚ
⊢ 0 < toNNRat q ↔ 0 < q

Next tactic:
simp [toNNRat, ← coe_lt_coe]
@[simp]
theorem toNNRat_eq_zero : toNNRat q = 0 ↔ q ≤ 0 := by
  

Proof state:
p q : ℚ
⊢ toNNRat q = 0 ↔ q ≤ 0

Next tactic:
simpa [-toNNRat_pos] using (@toNNRat_pos q).not
@[simp]
theorem toNNRat_le_toNNRat_iff (hp : 0 ≤ p) : toNNRat q ≤ toNNRat p ↔ q ≤ p := by
  

Proof state:
p q : ℚ
hp : 0 ≤ p
⊢ toNNRat q ≤ toNNRat p ↔ q ≤ p

Next tactic:
simp [← coe_le_coe, toNNRat, hp]
@[simp]
theorem toNNRat_lt_toNNRat_iff' : toNNRat q < toNNRat p ↔ q < p ∧ 0 < p := by
  

Proof state:
p q : ℚ
⊢ toNNRat q < toNNRat p ↔ q < p ∧ 0 < p

Next tactic:
simp [← coe_lt_coe, toNNRat, lt_irrefl]
@[simp]
theorem toNNRat_add (hq : 0 ≤ q) (hp : 0 ≤ p) : toNNRat (q + p) = toNNRat q + toNNRat p :=
  NNRat.ext <| by 

Proof state:
p q : ℚ
hq : 0 ≤ q
hp : 0 ≤ p
⊢ ↑(toNNRat (q + p)) = ↑(toNNRat q + toNNRat p)

Next tactic:
simp [toNNRat, hq, hp, add_nonneg]
theorem le_toNNRat_iff_coe_le {q : ℚ≥0} (hp : 0 ≤ p) : q ≤ toNNRat p ↔ ↑q ≤ p := by
  

Proof state:
p q✝ : ℚ
q : ℚ≥0
hp : 0 ≤ p
⊢ q ≤ toNNRat p ↔ ↑q ≤ p

Next tactic:
rw [← coe_le_coe, Rat.coe_toNNRat p hp]
theorem le_toNNRat_iff_coe_le' {q : ℚ≥0} (hq : 0 < q) : q ≤ toNNRat p ↔ ↑q ≤ p :=
  (le_or_lt 0 p).elim le_toNNRat_iff_coe_le fun hp ↦ by
    

Proof state:
p q✝ : ℚ
q : ℚ≥0
hq : 0 < q
hp : p < 0
⊢ q ≤ toNNRat p ↔ ↑q ≤ p

Next tactic:
simp only [(hp.trans_le q.coe_nonneg).not_le, toNNRat_eq_zero.2 hp.le, hq.not_le]
theorem toNNRat_lt_iff_lt_coe {p : ℚ≥0} (hq : 0 ≤ q) : toNNRat q < p ↔ q < ↑p := by
  

Proof state:
p✝ q : ℚ
p : ℚ≥0
hq : 0 ≤ q
⊢ toNNRat q < p ↔ q < ↑p

Next tactic:
rw [← coe_lt_coe, Rat.coe_toNNRat q hq]
theorem toNNRat_mul (hp : 0 ≤ p) : toNNRat (p * q) = toNNRat p * toNNRat q := by
  

Proof state:
p q : ℚ
hp : 0 ≤ p
⊢ toNNRat (p * q) = toNNRat p * toNNRat q

Next tactic:
rcases le_total 0 q with hq | hq
theorem toNNRat_mul (hp : 0 ≤ p) : toNNRat (p * q) = toNNRat p * toNNRat q := by
  rcases le_total 0 q with hq | hq
  · 

Proof state:
case inl
p q : ℚ
hp : 0 ≤ p
hq : 0 ≤ q
⊢ toNNRat (p * q) = toNNRat p * toNNRat q

Next tactic:
ext
theorem toNNRat_mul (hp : 0 ≤ p) : toNNRat (p * q) = toNNRat p * toNNRat q := by
  rcases le_total 0 q with hq | hq
  · ext <;> 

Proof state:
case inl.a.num
p q : ℚ
hp : 0 ≤ p
hq : 0 ≤ q
⊢ (↑(toNNRat (p * q))).num = (↑(toNNRat p * toNNRat q)).num

Next tactic:
simp [toNNRat, hp, hq, max_eq_left, mul_nonneg]
theorem toNNRat_mul (hp : 0 ≤ p) : toNNRat (p * q) = toNNRat p * toNNRat q := by
  rcases le_total 0 q with hq | hq
  · ext <;> 

Proof state:
case inl.a.den
p q : ℚ
hp : 0 ≤ p
hq : 0 ≤ q
⊢ (↑(toNNRat (p * q))).den = (↑(toNNRat p * toNNRat q)).den

Next tactic:
simp [toNNRat, hp, hq, max_eq_left, mul_nonneg]
theorem toNNRat_mul (hp : 0 ≤ p) : toNNRat (p * q) = toNNRat p * toNNRat q := by
  rcases le_total 0 q with hq | hq
  · ext <;> simp [toNNRat, hp, hq, max_eq_left, mul_nonneg]
  · 

Proof state:
case inr
p q : ℚ
hp : 0 ≤ p
hq : q ≤ 0
⊢ toNNRat (p * q) = toNNRat p * toNNRat q

Next tactic:
have hpq := mul_nonpos_of_nonneg_of_nonpos hp hq
theorem toNNRat_mul (hp : 0 ≤ p) : toNNRat (p * q) = toNNRat p * toNNRat q := by
  rcases le_total 0 q with hq | hq
  · ext <;> simp [toNNRat, hp, hq, max_eq_left, mul_nonneg]
  · have hpq := mul_nonpos_of_nonneg_of_nonpos hp hq
    

Proof state:
case inr
p q : ℚ
hp : 0 ≤ p
hq : q ≤ 0
hpq : p * q ≤ 0
⊢ toNNRat (p * q) = toNNRat p * toNNRat q

Next tactic:
rw [toNNRat_eq_zero.2 hq, toNNRat_eq_zero.2 hpq, mul_zero]
theorem toNNRat_inv (q : ℚ) : toNNRat q⁻¹ = (toNNRat q)⁻¹ := by
  

Proof state:
p q✝ q : ℚ
⊢ toNNRat q⁻¹ = (toNNRat q)⁻¹

Next tactic:
obtain hq | hq := le_total q 0
theorem toNNRat_inv (q : ℚ) : toNNRat q⁻¹ = (toNNRat q)⁻¹ := by
  obtain hq | hq := le_total q 0
  · 

Proof state:
case inl
p q✝ q : ℚ
hq : q ≤ 0
⊢ toNNRat q⁻¹ = (toNNRat q)⁻¹

Next tactic:
rw [toNNRat_eq_zero.mpr hq, inv_zero, toNNRat_eq_zero.mpr (inv_nonpos.mpr hq)]
theorem toNNRat_inv (q : ℚ) : toNNRat q⁻¹ = (toNNRat q)⁻¹ := by
  obtain hq | hq := le_total q 0
  · rw [toNNRat_eq_zero.mpr hq, inv_zero, toNNRat_eq_zero.mpr (inv_nonpos.mpr hq)]
  · 

Proof state:
case inr
p q✝ q : ℚ
hq : 0 ≤ q
⊢ toNNRat q⁻¹ = (toNNRat q)⁻¹

Next tactic:
nth_rw 1 [← Rat.coe_toNNRat q hq]
theorem toNNRat_inv (q : ℚ) : toNNRat q⁻¹ = (toNNRat q)⁻¹ := by
  obtain hq | hq := le_total q 0
  · rw [toNNRat_eq_zero.mpr hq, inv_zero, toNNRat_eq_zero.mpr (inv_nonpos.mpr hq)]
  · nth_rw 1 [← Rat.coe_toNNRat q hq]
    

Proof state:
case inr
p q✝ q : ℚ
hq : 0 ≤ q
⊢ toNNRat (↑(toNNRat q))⁻¹ = (toNNRat q)⁻¹

Next tactic:
rw [← coe_inv, toNNRat_coe]
theorem toNNRat_div (hp : 0 ≤ p) : toNNRat (p / q) = toNNRat p / toNNRat q := by
  

Proof state:
p q : ℚ
hp : 0 ≤ p
⊢ toNNRat (p / q) = toNNRat p / toNNRat q

Next tactic:
rw [div_eq_mul_inv, div_eq_mul_inv, ← toNNRat_inv, ← toNNRat_mul hp]
theorem toNNRat_div' (hq : 0 ≤ q) : toNNRat (p / q) = toNNRat p / toNNRat q := by
  

Proof state:
p q : ℚ
hq : 0 ≤ q
⊢ toNNRat (p / q) = toNNRat p / toNNRat q

Next tactic:
rw [div_eq_inv_mul, div_eq_inv_mul, toNNRat_mul (inv_nonneg.2 hq), toNNRat_inv]
theorem ext_num_den (hn : p.num = q.num) (hd : p.den = q.den) : p = q := by
  

Proof state:
p q : ℚ≥0
hn : num p = num q
hd : den p = den q
⊢ p = q

Next tactic:
ext
theorem ext_num_den (hn : p.num = q.num) (hd : p.den = q.den) : p = q := by
  ext
  · 

Proof state:
case a.num
p q : ℚ≥0
hn : num p = num q
hd : den p = den q
⊢ (↑p).num = (↑q).num

Next tactic:
apply (Int.natAbs_inj_of_nonneg_of_nonneg _ _).1 hn
theorem ext_num_den (hn : p.num = q.num) (hd : p.den = q.den) : p = q := by
  ext
  · apply (Int.natAbs_inj_of_nonneg_of_nonneg _ _).1 hn
    

Proof state:
p q : ℚ≥0
hn : num p = num q
hd : den p = den q
⊢ 0 ≤ (↑p).num
p q : ℚ≥0 hn : num p = num q hd : den p = den q ⊢ 0 ≤ (↑q).num

Next tactic:
exact Rat.num_nonneg_iff_zero_le.2 p.2
theorem ext_num_den (hn : p.num = q.num) (hd : p.den = q.den) : p = q := by
  ext
  · apply (Int.natAbs_inj_of_nonneg_of_nonneg _ _).1 hn
    exact Rat.num_nonneg_iff_zero_le.2 p.2
    

Proof state:
p q : ℚ≥0
hn : num p = num q
hd : den p = den q
⊢ 0 ≤ (↑q).num

Next tactic:
exact Rat.num_nonneg_iff_zero_le.2 q.2
theorem ext_num_den (hn : p.num = q.num) (hd : p.den = q.den) : p = q := by
  ext
  · apply (Int.natAbs_inj_of_nonneg_of_nonneg _ _).1 hn
    exact Rat.num_nonneg_iff_zero_le.2 p.2
    exact Rat.num_nonneg_iff_zero_le.2 q.2
  · 

Proof state:
case a.den
p q : ℚ≥0
hn : num p = num q
hd : den p = den q
⊢ (↑p).den = (↑q).den

Next tactic:
exact hd
theorem ext_num_den_iff : p = q ↔ p.num = q.num ∧ p.den = q.den :=
  ⟨by 

Proof state:
p q : ℚ≥0
⊢ p = q → num p = num q ∧ den p = den q

Next tactic:
rintro rfl
theorem ext_num_den_iff : p = q ↔ p.num = q.num ∧ p.den = q.den :=
  ⟨by rintro rfl; 

Proof state:
p : ℚ≥0
⊢ num p = num p ∧ den p = den p

Next tactic:
exact ⟨rfl, rfl⟩
@[simp]
theorem num_div_den (q : ℚ≥0) : (q.num : ℚ≥0) / q.den = q := by
  

Proof state:
p q✝ q : ℚ≥0
⊢ ↑(num q) / ↑(den q) = q

Next tactic:
ext1
@[simp]
theorem num_div_den (q : ℚ≥0) : (q.num : ℚ≥0) / q.den = q := by
  ext1
  

Proof state:
case a
p q✝ q : ℚ≥0
⊢ ↑(↑(num q) / ↑(den q)) = ↑q

Next tactic:
rw [coe_div, coe_natCast, coe_natCast, num, ← Int.cast_ofNat,
    Int.natAbs_of_nonneg (Rat.num_nonneg_iff_zero_le.2 q.prop)]
@[simp]
theorem num_div_den (q : ℚ≥0) : (q.num : ℚ≥0) / q.den = q := by
  ext1
  rw [coe_div, coe_natCast, coe_natCast, num, ← Int.cast_ofNat,
    Int.natAbs_of_nonneg (Rat.num_nonneg_iff_zero_le.2 q.prop)]
  

Proof state:
case a
p q✝ q : ℚ≥0
⊢ ↑(↑q).num / ↑(den q) = ↑q

Next tactic:
exact Rat.num_div_den q
/-- A recursor for nonnegative rationals in terms of numerators and denominators. -/
protected def rec {α : ℚ≥0 → Sort*} (h : ∀ m n : ℕ, α (m / n)) (q : ℚ≥0) : α q := by
  

Proof state:
p q✝ : ℚ≥0
α : ℚ≥0 → Sort u_1
h : (m n : ℕ) → α (↑m / ↑n)
q : ℚ≥0
⊢ α q

Next tactic:
rw [← num_div_den q]
/-- A recursor for nonnegative rationals in terms of numerators and denominators. -/
protected def rec {α : ℚ≥0 → Sort*} (h : ∀ m n : ℕ, α (m / n)) (q : ℚ≥0) : α q := by
  rw [← num_div_den q]
  

Proof state:
p q✝ : ℚ≥0
α : ℚ≥0 → Sort u_1
h : (m n : ℕ) → α (↑m / ↑n)
q : ℚ≥0
⊢ α (↑(num q) / ↑(den q))

Next tactic:
apply h
/-- The kernel of a group homomorphism is a kernel in the categorical sense. -/
def kernelIsLimit : IsLimit <| kernelCone f :=
  Fork.IsLimit.mk _
    (fun s => (by 

Proof state:
G H : AddCommGroupCat
f : G ⟶ H
s : Fork f 0
⊢ ↑s.pt →+ ↑G

Next tactic:
exact Fork.ι s
/-- The kernel of a group homomorphism is a kernel in the categorical sense. -/
def kernelIsLimit : IsLimit <| kernelCone f :=
  Fork.IsLimit.mk _
    (fun s => (by exact Fork.ι s : _ →+ G).codRestrict _ <| fun c => f.mem_ker.mpr <|
      by 

Proof state:
G H : AddCommGroupCat
f : G ⟶ H
s : Fork f 0
c : ↑s.pt
⊢ f ((Fork.ι s) c) = 0

Next tactic:
exact FunLike.congr_fun s.condition c
/-- The kernel of a group homomorphism is a kernel in the categorical sense. -/
def kernelIsLimit : IsLimit <| kernelCone f :=
  Fork.IsLimit.mk _
    (fun s => (by exact Fork.ι s : _ →+ G).codRestrict _ <| fun c => f.mem_ker.mpr <|
      by exact FunLike.congr_fun s.condition c)
    (fun _ => by 

Proof state:
G H : AddCommGroupCat
f : G ⟶ H
x✝ : Fork f 0
⊢ (fun s => codRestrict (Fork.ι s) (ker f) (_ : ∀ (c : ↑s.pt), (Fork.ι s) c ∈ ker f)) x✝ ≫ Fork.ι (kernelCone f) =
    Fork.ι x✝

Next tactic:
rfl
/-- The kernel of a group homomorphism is a kernel in the categorical sense. -/
def kernelIsLimit : IsLimit <| kernelCone f :=
  Fork.IsLimit.mk _
    (fun s => (by exact Fork.ι s : _ →+ G).codRestrict _ <| fun c => f.mem_ker.mpr <|
      by exact FunLike.congr_fun s.condition c)
    (fun _ => by rfl)
    (fun _ _ h => ext fun x => Subtype.ext_iff_val.mpr <| by 

Proof state:
G H : AddCommGroupCat
f : G ⟶ H
x✝¹ : Fork f 0
x✝ : x✝¹.pt ⟶ (kernelCone f).pt
h : x✝ ≫ Fork.ι (kernelCone f) = Fork.ι x✝¹
x : ↑x✝¹.pt
⊢ ↑(x✝ x) = ↑(((fun s => codRestrict (Fork.ι s) (ker f) (_ : ∀ (c : ↑s.pt), (Fork.ι s) c ∈ ker f)) x✝¹) x)

Next tactic:
exact FunLike.congr_fun h x
/-- The projection onto the quotient is a cokernel in the categorical sense. -/
def cokernelIsColimit : IsColimit <| cokernelCocone f :=
  Cofork.IsColimit.mk _
    (fun s => lift _ _ <| (range_le_ker_iff _ _).mpr <| CokernelCofork.condition s)
    (fun _ => rfl)
    (fun _ _ h => have : Epi (cokernelCocone f).π := (epi_iff_surjective _).mpr <| mk'_surjective _
      (cancel_epi _).mp <| by 

Proof state:
G H : AddCommGroupCat
f : G ⟶ H
x✝¹ : Cofork f 0
x✝ : (cokernelCocone f).pt ⟶ x✝¹.pt
h : Cofork.π (cokernelCocone f) ≫ x✝ = Cofork.π x✝¹
this : Epi (Cofork.π (cokernelCocone f))
⊢ ?m.55789 x✝¹ x✝ h this ≫ x✝ =
    ?m.55789 x✝¹ x✝ h this ≫ (fun s => lift (range f) (Cofork.π s) (_ : range f ≤ ker (Cofork.π s))) x✝¹

Next tactic:
simpa only [parallelPair_obj_one] using h
instance decidableMemIoo [Decidable (a < x ∧ x < b)] : Decidable (x ∈ Ioo a b) := by 

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : Decidable (a < x ∧ x < b)
⊢ Decidable (x ∈ Ioo a b)

Next tactic:
assumption
instance decidableMemIco [Decidable (a ≤ x ∧ x < b)] : Decidable (x ∈ Ico a b) := by 

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : Decidable (a ≤ x ∧ x < b)
⊢ Decidable (x ∈ Ico a b)

Next tactic:
assumption
instance decidableMemIio [Decidable (x < b)] : Decidable (x ∈ Iio b) := by 

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : Decidable (x < b)
⊢ Decidable (x ∈ Iio b)

Next tactic:
assumption
instance decidableMemIcc [Decidable (a ≤ x ∧ x ≤ b)] : Decidable (x ∈ Icc a b) := by 

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : Decidable (a ≤ x ∧ x ≤ b)
⊢ Decidable (x ∈ Icc a b)

Next tactic:
assumption
instance decidableMemIic [Decidable (x ≤ b)] : Decidable (x ∈ Iic b) := by 

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : Decidable (x ≤ b)
⊢ Decidable (x ∈ Iic b)

Next tactic:
assumption
instance decidableMemIoc [Decidable (a < x ∧ x ≤ b)] : Decidable (x ∈ Ioc a b) := by 

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : Decidable (a < x ∧ x ≤ b)
⊢ Decidable (x ∈ Ioc a b)

Next tactic:
assumption
instance decidableMemIci [Decidable (a ≤ x)] : Decidable (x ∈ Ici a) := by 

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : Decidable (a ≤ x)
⊢ Decidable (x ∈ Ici a)

Next tactic:
assumption
instance decidableMemIoi [Decidable (a < x)] : Decidable (x ∈ Ioi a) := by 

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : Decidable (a < x)
⊢ Decidable (x ∈ Ioi a)

Next tactic:
assumption
theorem left_mem_Ioo : a ∈ Ioo a b ↔ False := by 

Proof state:
α : Type u_1
β : Type u_2
inst✝ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
⊢ a ∈ Ioo a b ↔ False

Next tactic:
simp [lt_irrefl]
theorem left_mem_Ico : a ∈ Ico a b ↔ a < b := by 

Proof state:
α : Type u_1
β : Type u_2
inst✝ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
⊢ a ∈ Ico a b ↔ a < b

Next tactic:
simp [le_refl]
theorem left_mem_Icc : a ∈ Icc a b ↔ a ≤ b := by 

Proof state:
α : Type u_1
β : Type u_2
inst✝ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
⊢ a ∈ Icc a b ↔ a ≤ b

Next tactic:
simp [le_refl]
theorem left_mem_Ioc : a ∈ Ioc a b ↔ False := by 

Proof state:
α : Type u_1
β : Type u_2
inst✝ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
⊢ a ∈ Ioc a b ↔ False

Next tactic:
simp [lt_irrefl]
theorem left_mem_Ici : a ∈ Ici a := by 

Proof state:
α : Type u_1
β : Type u_2
inst✝ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
⊢ a ∈ Ici a

Next tactic:
simp
theorem right_mem_Ioo : b ∈ Ioo a b ↔ False := by 

Proof state:
α : Type u_1
β : Type u_2
inst✝ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
⊢ b ∈ Ioo a b ↔ False

Next tactic:
simp [lt_irrefl]
theorem right_mem_Ico : b ∈ Ico a b ↔ False := by 

Proof state:
α : Type u_1
β : Type u_2
inst✝ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
⊢ b ∈ Ico a b ↔ False

Next tactic:
simp [lt_irrefl]
theorem right_mem_Icc : b ∈ Icc a b ↔ a ≤ b := by 

Proof state:
α : Type u_1
β : Type u_2
inst✝ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
⊢ b ∈ Icc a b ↔ a ≤ b

Next tactic:
simp [le_refl]
theorem right_mem_Ioc : b ∈ Ioc a b ↔ a < b := by 

Proof state:
α : Type u_1
β : Type u_2
inst✝ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
⊢ b ∈ Ioc a b ↔ a < b

Next tactic:
simp [le_refl]
theorem right_mem_Iic : a ∈ Iic a := by 

Proof state:
α : Type u_1
β : Type u_2
inst✝ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
⊢ a ∈ Iic a

Next tactic:
simp
theorem Icc_eq_empty_iff : Icc a b = ∅ ↔ ¬a ≤ b := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
⊢ Icc a b = ∅ ↔ ¬a ≤ b

Next tactic:
rw [← not_nonempty_iff_eq_empty, not_iff_not, nonempty_Icc]
theorem Ico_eq_empty_iff : Ico a b = ∅ ↔ ¬a < b := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
⊢ Ico a b = ∅ ↔ ¬a < b

Next tactic:
rw [← not_nonempty_iff_eq_empty, not_iff_not, nonempty_Ico]
theorem Ioc_eq_empty_iff : Ioc a b = ∅ ↔ ¬a < b := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
⊢ Ioc a b = ∅ ↔ ¬a < b

Next tactic:
rw [← not_nonempty_iff_eq_empty, not_iff_not, nonempty_Ioc]
theorem Ioo_eq_empty_iff [DenselyOrdered α] : Ioo a b = ∅ ↔ ¬a < b := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : Preorder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : DenselyOrdered α
⊢ Ioo a b = ∅ ↔ ¬a < b

Next tactic:
rw [← not_nonempty_iff_eq_empty, not_iff_not, nonempty_Ioo]
@[simp]
theorem Icc_self (a : α) : Icc a a = {a} :=
  Set.ext <| by 

Proof state:
α : Type u_1
β : Type u_2
inst✝ : PartialOrder α
a✝ b c a : α
⊢ ∀ (x : α), x ∈ Icc a a ↔ x ∈ {a}

Next tactic:
simp [Icc, le_antisymm_iff, and_comm]
@[simp]
theorem Icc_eq_singleton_iff : Icc a b = {c} ↔ a = c ∧ b = c := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝ : PartialOrder α
a b c : α
⊢ Icc a b = {c} ↔ a = c ∧ b = c

Next tactic:
refine' ⟨fun h => _, _⟩
@[simp]
theorem Icc_eq_singleton_iff : Icc a b = {c} ↔ a = c ∧ b = c := by
  refine' ⟨fun h => _, _⟩
  · 

Proof state:
case refine'_1
α : Type u_1
β : Type u_2
inst✝ : PartialOrder α
a b c : α
h : Icc a b = {c}
⊢ a = c ∧ b = c

Next tactic:
have hab : a ≤ b := nonempty_Icc.1 (h.symm.subst <| singleton_nonempty c)
@[simp]
theorem Icc_eq_singleton_iff : Icc a b = {c} ↔ a = c ∧ b = c := by
  refine' ⟨fun h => _, _⟩
  · have hab : a ≤ b := nonempty_Icc.1 (h.symm.subst <| singleton_nonempty c)
    

Proof state:
case refine'_1
α : Type u_1
β : Type u_2
inst✝ : PartialOrder α
a b c : α
h : Icc a b = {c}
hab : a ≤ b
⊢ a = c ∧ b = c

Next tactic:
exact
      ⟨eq_of_mem_singleton <| h.subst <| left_mem_Icc.2 hab,
        eq_of_mem_singleton <| h.subst <| right_mem_Icc.2 hab⟩
@[simp]
theorem Icc_eq_singleton_iff : Icc a b = {c} ↔ a = c ∧ b = c := by
  refine' ⟨fun h => _, _⟩
  · have hab : a ≤ b := nonempty_Icc.1 (h.symm.subst <| singleton_nonempty c)
    exact
      ⟨eq_of_mem_singleton <| h.subst <| left_mem_Icc.2 hab,
        eq_of_mem_singleton <| h.subst <| right_mem_Icc.2 hab⟩
  · 

Proof state:
case refine'_2
α : Type u_1
β : Type u_2
inst✝ : PartialOrder α
a b c : α
⊢ a = c ∧ b = c → Icc a b = {c}

Next tactic:
rintro ⟨rfl, rfl⟩
@[simp]
theorem Icc_eq_singleton_iff : Icc a b = {c} ↔ a = c ∧ b = c := by
  refine' ⟨fun h => _, _⟩
  · have hab : a ≤ b := nonempty_Icc.1 (h.symm.subst <| singleton_nonempty c)
    exact
      ⟨eq_of_mem_singleton <| h.subst <| left_mem_Icc.2 hab,
        eq_of_mem_singleton <| h.subst <| right_mem_Icc.2 hab⟩
  · rintro ⟨rfl, rfl⟩
    

Proof state:
case refine'_2.intro
α : Type u_1
β : Type u_2
inst✝ : PartialOrder α
b : α
⊢ Icc b b = {b}

Next tactic:
exact Icc_self _
@[simp] lemma subsingleton_Icc_iff {α : Type*} [LinearOrder α] {a b : α} :
    Set.Subsingleton (Icc a b) ↔ b ≤ a := by
  

Proof state:
α✝ : Type u_1
β : Type u_2
inst✝¹ : PartialOrder α✝
a✝ b✝ c : α✝
α : Type u_3
inst✝ : LinearOrder α
a b : α
⊢ Set.Subsingleton (Icc a b) ↔ b ≤ a

Next tactic:
refine' ⟨fun h ↦ _, subsingleton_Icc_of_ge⟩
@[simp] lemma subsingleton_Icc_iff {α : Type*} [LinearOrder α] {a b : α} :
    Set.Subsingleton (Icc a b) ↔ b ≤ a := by
  refine' ⟨fun h ↦ _, subsingleton_Icc_of_ge⟩
  

Proof state:
α✝ : Type u_1
β : Type u_2
inst✝¹ : PartialOrder α✝
a✝ b✝ c : α✝
α : Type u_3
inst✝ : LinearOrder α
a b : α
h : Set.Subsingleton (Icc a b)
⊢ b ≤ a

Next tactic:
contrapose! h
@[simp] lemma subsingleton_Icc_iff {α : Type*} [LinearOrder α] {a b : α} :
    Set.Subsingleton (Icc a b) ↔ b ≤ a := by
  refine' ⟨fun h ↦ _, subsingleton_Icc_of_ge⟩
  contrapose! h
  

Proof state:
α✝ : Type u_1
β : Type u_2
inst✝¹ : PartialOrder α✝
a✝ b✝ c : α✝
α : Type u_3
inst✝ : LinearOrder α
a b : α
h : a < b
⊢ ¬Set.Subsingleton (Icc a b)

Next tactic:
simp only [ge_iff_le, gt_iff_lt, not_subsingleton_iff]
@[simp] lemma subsingleton_Icc_iff {α : Type*} [LinearOrder α] {a b : α} :
    Set.Subsingleton (Icc a b) ↔ b ≤ a := by
  refine' ⟨fun h ↦ _, subsingleton_Icc_of_ge⟩
  contrapose! h
  simp only [ge_iff_le, gt_iff_lt, not_subsingleton_iff]
  

Proof state:
α✝ : Type u_1
β : Type u_2
inst✝¹ : PartialOrder α✝
a✝ b✝ c : α✝
α : Type u_3
inst✝ : LinearOrder α
a b : α
h : a < b
⊢ Set.Nontrivial (Icc a b)

Next tactic:
exact ⟨a, ⟨le_refl _, h.le⟩, b, ⟨h.le, le_refl _⟩, h.ne⟩
@[simp]
theorem Icc_diff_left : Icc a b \ {a} = Ioc a b :=
  ext fun x => by 

Proof state:
α : Type u_1
β : Type u_2
inst✝ : PartialOrder α
a b c x : α
⊢ x ∈ Icc a b \ {a} ↔ x ∈ Ioc a b

Next tactic:
simp [lt_iff_le_and_ne, eq_comm, and_right_comm]
@[simp]
theorem Icc_diff_right : Icc a b \ {b} = Ico a b :=
  ext fun x => by 

Proof state:
α : Type u_1
β : Type u_2
inst✝ : PartialOrder α
a b c x : α
⊢ x ∈ Icc a b \ {b} ↔ x ∈ Ico a b

Next tactic:
simp [lt_iff_le_and_ne, and_assoc]
@[simp]
theorem Ico_diff_left : Ico a b \ {a} = Ioo a b :=
  ext fun x => by 

Proof state:
α : Type u_1
β : Type u_2
inst✝ : PartialOrder α
a b c x : α
⊢ x ∈ Ico a b \ {a} ↔ x ∈ Ioo a b

Next tactic:
simp [and_right_comm, ← lt_iff_le_and_ne, eq_comm]
@[simp]
theorem Ioc_diff_right : Ioc a b \ {b} = Ioo a b :=
  ext fun x => by 

Proof state:
α : Type u_1
β : Type u_2
inst✝ : PartialOrder α
a b c x : α
⊢ x ∈ Ioc a b \ {b} ↔ x ∈ Ioo a b

Next tactic:
simp [and_assoc, ← lt_iff_le_and_ne]
@[simp]
theorem Icc_diff_both : Icc a b \ {a, b} = Ioo a b := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝ : PartialOrder α
a b c : α
⊢ Icc a b \ {a, b} = Ioo a b

Next tactic:
rw [insert_eq, ← diff_diff, Icc_diff_left, Ioc_diff_right]
@[simp]
theorem Ici_diff_left : Ici a \ {a} = Ioi a :=
  ext fun x => by 

Proof state:
α : Type u_1
β : Type u_2
inst✝ : PartialOrder α
a b c x : α
⊢ x ∈ Ici a \ {a} ↔ x ∈ Ioi a

Next tactic:
simp [lt_iff_le_and_ne, eq_comm]
@[simp]
theorem Iic_diff_right : Iic a \ {a} = Iio a :=
  ext fun x => by 

Proof state:
α : Type u_1
β : Type u_2
inst✝ : PartialOrder α
a b c x : α
⊢ x ∈ Iic a \ {a} ↔ x ∈ Iio a

Next tactic:
simp [lt_iff_le_and_ne]
@[simp]
theorem Ico_diff_Ioo_same (h : a < b) : Ico a b \ Ioo a b = {a} := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝ : PartialOrder α
a b c : α
h : a < b
⊢ Ico a b \ Ioo a b = {a}

Next tactic:
rw [← Ico_diff_left, diff_diff_cancel_left (singleton_subset_iff.2 <| left_mem_Ico.2 h)]
@[simp]
theorem Ioc_diff_Ioo_same (h : a < b) : Ioc a b \ Ioo a b = {b} := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝ : PartialOrder α
a b c : α
h : a < b
⊢ Ioc a b \ Ioo a b = {b}

Next tactic:
rw [← Ioc_diff_right, diff_diff_cancel_left (singleton_subset_iff.2 <| right_mem_Ioc.2 h)]