l3lab/ntp-mathlib huggingface dataset:
theorem _root_.BddBelow.finite_of_bddAbove {s : Set α} (h₀ : BddBelow s) (h₁ : BddAbove s) :
    s.Finite := by
  let ⟨a, ha⟩ := h₀
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝¹ : Preorder α
inst✝ : LocallyFiniteOrder α
a✝ a₁ a₂ b b₁ b₂ c x : α
s : Set α
h₀ : BddBelow s
h₁ : BddAbove s
a : α
ha : a ∈ lowerBounds s
⊢ Set.Finite s

Next tactic:
let ⟨b, hb⟩ := h₁
theorem _root_.BddBelow.finite_of_bddAbove {s : Set α} (h₀ : BddBelow s) (h₁ : BddAbove s) :
    s.Finite := by
  let ⟨a, ha⟩ := h₀
  let ⟨b, hb⟩ := h₁
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝¹ : Preorder α
inst✝ : LocallyFiniteOrder α
a✝ a₁ a₂ b✝ b₁ b₂ c x : α
s : Set α
h₀ : BddBelow s
h₁ : BddAbove s
a : α
ha : a ∈ lowerBounds s
b : α
hb : b ∈ upperBounds s
⊢ Set.Finite s

Next tactic:
classical exact ⟨Set.fintypeOfMemBounds ha hb⟩
theorem _root_.BddBelow.finite_of_bddAbove {s : Set α} (h₀ : BddBelow s) (h₁ : BddAbove s) :
    s.Finite := by
  let ⟨a, ha⟩ := h₀
  let ⟨b, hb⟩ := h₁
  classical 

Proof state:
ι : Type u_1
α : Type u_2
inst✝¹ : Preorder α
inst✝ : LocallyFiniteOrder α
a✝ a₁ a₂ b✝ b₁ b₂ c x : α
s : Set α
h₀ : BddBelow s
h₁ : BddAbove s
a : α
ha : a ∈ lowerBounds s
b : α
hb : b ∈ upperBounds s
⊢ Set.Finite s

Next tactic:
exact ⟨Set.fintypeOfMemBounds ha hb⟩
theorem Ico_filter_lt_of_le_right [DecidablePred (· < c)] (hcb : c ≤ b) :
    (Ico a b).filter (· < c) = Ico a c := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : Preorder α
inst✝¹ : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : DecidablePred fun x => x < c
hcb : c ≤ b
⊢ filter (fun x => x < c) (Ico a b) = Ico a c

Next tactic:
ext x
theorem Ico_filter_lt_of_le_right [DecidablePred (· < c)] (hcb : c ≤ b) :
    (Ico a b).filter (· < c) = Ico a c := by
  ext x
  

Proof state:
case a
ι : Type u_1
α : Type u_2
inst✝² : Preorder α
inst✝¹ : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x✝ : α
inst✝ : DecidablePred fun x => x < c
hcb : c ≤ b
x : α
⊢ x ∈ filter (fun x => x < c) (Ico a b) ↔ x ∈ Ico a c

Next tactic:
rw [mem_filter, mem_Ico, mem_Ico, and_right_comm]
theorem Ico_filter_lt_of_le_right [DecidablePred (· < c)] (hcb : c ≤ b) :
    (Ico a b).filter (· < c) = Ico a c := by
  ext x
  rw [mem_filter, mem_Ico, mem_Ico, and_right_comm]
  

Proof state:
case a
ι : Type u_1
α : Type u_2
inst✝² : Preorder α
inst✝¹ : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x✝ : α
inst✝ : DecidablePred fun x => x < c
hcb : c ≤ b
x : α
⊢ (a ≤ x ∧ x < c) ∧ x < b ↔ a ≤ x ∧ x < c

Next tactic:
exact and_iff_left_of_imp fun h => h.2.trans_le hcb
theorem Ico_filter_le_of_left_le {a b c : α} [DecidablePred (c ≤ ·)] (hac : a ≤ c) :
    (Ico a b).filter (c ≤ ·) = Ico c b := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : Preorder α
inst✝¹ : LocallyFiniteOrder α
a✝ a₁ a₂ b✝ b₁ b₂ c✝ x a b c : α
inst✝ : DecidablePred fun x => c ≤ x
hac : a ≤ c
⊢ filter (fun x => c ≤ x) (Ico a b) = Ico c b

Next tactic:
ext x
theorem Ico_filter_le_of_left_le {a b c : α} [DecidablePred (c ≤ ·)] (hac : a ≤ c) :
    (Ico a b).filter (c ≤ ·) = Ico c b := by
  ext x
  

Proof state:
case a
ι : Type u_1
α : Type u_2
inst✝² : Preorder α
inst✝¹ : LocallyFiniteOrder α
a✝ a₁ a₂ b✝ b₁ b₂ c✝ x✝ a b c : α
inst✝ : DecidablePred fun x => c ≤ x
hac : a ≤ c
x : α
⊢ x ∈ filter (fun x => c ≤ x) (Ico a b) ↔ x ∈ Ico c b

Next tactic:
rw [mem_filter, mem_Ico, mem_Ico, and_comm, and_left_comm]
theorem Ico_filter_le_of_left_le {a b c : α} [DecidablePred (c ≤ ·)] (hac : a ≤ c) :
    (Ico a b).filter (c ≤ ·) = Ico c b := by
  ext x
  rw [mem_filter, mem_Ico, mem_Ico, and_comm, and_left_comm]
  

Proof state:
case a
ι : Type u_1
α : Type u_2
inst✝² : Preorder α
inst✝¹ : LocallyFiniteOrder α
a✝ a₁ a₂ b✝ b₁ b₂ c✝ x✝ a b c : α
inst✝ : DecidablePred fun x => c ≤ x
hac : a ≤ c
x : α
⊢ a ≤ x ∧ c ≤ x ∧ x < b ↔ c ≤ x ∧ x < b

Next tactic:
exact and_iff_right_of_imp fun h => hac.trans h.1
theorem filter_lt_lt_eq_Ioo [DecidablePred fun j => a < j ∧ j < b] :
    (univ.filter fun j => a < j ∧ j < b) = Ioo a b := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝³ : Preorder α
inst✝² : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝¹ : Fintype α
inst✝ : DecidablePred fun j => a < j ∧ j < b
⊢ filter (fun j => a < j ∧ j < b) univ = Ioo a b

Next tactic:
ext
theorem filter_lt_lt_eq_Ioo [DecidablePred fun j => a < j ∧ j < b] :
    (univ.filter fun j => a < j ∧ j < b) = Ioo a b := by
  ext
  

Proof state:
case a
ι : Type u_1
α : Type u_2
inst✝³ : Preorder α
inst✝² : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝¹ : Fintype α
inst✝ : DecidablePred fun j => a < j ∧ j < b
a✝ : α
⊢ a✝ ∈ filter (fun j => a < j ∧ j < b) univ ↔ a✝ ∈ Ioo a b

Next tactic:
simp
theorem filter_lt_le_eq_Ioc [DecidablePred fun j => a < j ∧ j ≤ b] :
    (univ.filter fun j => a < j ∧ j ≤ b) = Ioc a b := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝³ : Preorder α
inst✝² : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝¹ : Fintype α
inst✝ : DecidablePred fun j => a < j ∧ j ≤ b
⊢ filter (fun j => a < j ∧ j ≤ b) univ = Ioc a b

Next tactic:
ext
theorem filter_lt_le_eq_Ioc [DecidablePred fun j => a < j ∧ j ≤ b] :
    (univ.filter fun j => a < j ∧ j ≤ b) = Ioc a b := by
  ext
  

Proof state:
case a
ι : Type u_1
α : Type u_2
inst✝³ : Preorder α
inst✝² : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝¹ : Fintype α
inst✝ : DecidablePred fun j => a < j ∧ j ≤ b
a✝ : α
⊢ a✝ ∈ filter (fun j => a < j ∧ j ≤ b) univ ↔ a✝ ∈ Ioc a b

Next tactic:
simp
theorem filter_le_lt_eq_Ico [DecidablePred fun j => a ≤ j ∧ j < b] :
    (univ.filter fun j => a ≤ j ∧ j < b) = Ico a b := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝³ : Preorder α
inst✝² : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝¹ : Fintype α
inst✝ : DecidablePred fun j => a ≤ j ∧ j < b
⊢ filter (fun j => a ≤ j ∧ j < b) univ = Ico a b

Next tactic:
ext
theorem filter_le_lt_eq_Ico [DecidablePred fun j => a ≤ j ∧ j < b] :
    (univ.filter fun j => a ≤ j ∧ j < b) = Ico a b := by
  ext
  

Proof state:
case a
ι : Type u_1
α : Type u_2
inst✝³ : Preorder α
inst✝² : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝¹ : Fintype α
inst✝ : DecidablePred fun j => a ≤ j ∧ j < b
a✝ : α
⊢ a✝ ∈ filter (fun j => a ≤ j ∧ j < b) univ ↔ a✝ ∈ Ico a b

Next tactic:
simp
theorem filter_le_le_eq_Icc [DecidablePred fun j => a ≤ j ∧ j ≤ b] :
    (univ.filter fun j => a ≤ j ∧ j ≤ b) = Icc a b := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝³ : Preorder α
inst✝² : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝¹ : Fintype α
inst✝ : DecidablePred fun j => a ≤ j ∧ j ≤ b
⊢ filter (fun j => a ≤ j ∧ j ≤ b) univ = Icc a b

Next tactic:
ext
theorem filter_le_le_eq_Icc [DecidablePred fun j => a ≤ j ∧ j ≤ b] :
    (univ.filter fun j => a ≤ j ∧ j ≤ b) = Icc a b := by
  ext
  

Proof state:
case a
ι : Type u_1
α : Type u_2
inst✝³ : Preorder α
inst✝² : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝¹ : Fintype α
inst✝ : DecidablePred fun j => a ≤ j ∧ j ≤ b
a✝ : α
⊢ a✝ ∈ filter (fun j => a ≤ j ∧ j ≤ b) univ ↔ a✝ ∈ Icc a b

Next tactic:
simp
@[simp] lemma nonempty_Ioi : (Ioi a).Nonempty ↔ ¬ IsMax a := by 

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : Preorder α
inst✝¹ : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : LocallyFiniteOrderTop α
⊢ Finset.Nonempty (Ioi a) ↔ ¬IsMax a

Next tactic:
simp [Finset.Nonempty]
theorem Icc_subset_Ici_self : Icc a b ⊆ Ici a := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : Preorder α
inst✝¹ : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : LocallyFiniteOrderTop α
⊢ Icc a b ⊆ Ici a

Next tactic:
simpa [← coe_subset] using Set.Icc_subset_Ici_self
theorem Ico_subset_Ici_self : Ico a b ⊆ Ici a := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : Preorder α
inst✝¹ : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : LocallyFiniteOrderTop α
⊢ Ico a b ⊆ Ici a

Next tactic:
simpa [← coe_subset] using Set.Ico_subset_Ici_self
theorem Ioc_subset_Ioi_self : Ioc a b ⊆ Ioi a := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : Preorder α
inst✝¹ : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : LocallyFiniteOrderTop α
⊢ Ioc a b ⊆ Ioi a

Next tactic:
simpa [← coe_subset] using Set.Ioc_subset_Ioi_self
theorem Ioo_subset_Ioi_self : Ioo a b ⊆ Ioi a := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : Preorder α
inst✝¹ : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : LocallyFiniteOrderTop α
⊢ Ioo a b ⊆ Ioi a

Next tactic:
simpa [← coe_subset] using Set.Ioo_subset_Ioi_self
@[simp] lemma nonempty_Iio : (Iio a).Nonempty ↔ ¬ IsMin a := by 

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : Preorder α
inst✝¹ : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : LocallyFiniteOrderBot α
⊢ Finset.Nonempty (Iio a) ↔ ¬IsMin a

Next tactic:
simp [Finset.Nonempty]
theorem Icc_subset_Iic_self : Icc a b ⊆ Iic b := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : Preorder α
inst✝¹ : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : LocallyFiniteOrderBot α
⊢ Icc a b ⊆ Iic b

Next tactic:
simpa [← coe_subset] using Set.Icc_subset_Iic_self
theorem Ioc_subset_Iic_self : Ioc a b ⊆ Iic b := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : Preorder α
inst✝¹ : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : LocallyFiniteOrderBot α
⊢ Ioc a b ⊆ Iic b

Next tactic:
simpa [← coe_subset] using Set.Ioc_subset_Iic_self
theorem Ico_subset_Iio_self : Ico a b ⊆ Iio b := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : Preorder α
inst✝¹ : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : LocallyFiniteOrderBot α
⊢ Ico a b ⊆ Iio b

Next tactic:
simpa [← coe_subset] using Set.Ico_subset_Iio_self
theorem Ioo_subset_Iio_self : Ioo a b ⊆ Iio b := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : Preorder α
inst✝¹ : LocallyFiniteOrder α
a a₁ a₂ b b₁ b₂ c x : α
inst✝ : LocallyFiniteOrderBot α
⊢ Ioo a b ⊆ Iio b

Next tactic:
simpa [← coe_subset] using Set.Ioo_subset_Iio_self
theorem Ioi_subset_Ici_self : Ioi a ⊆ Ici a := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝¹ : Preorder α
inst✝ : LocallyFiniteOrderTop α
a : α
⊢ Ioi a ⊆ Ici a

Next tactic:
simpa [← coe_subset] using Set.Ioi_subset_Ici_self
theorem filter_lt_eq_Ioi [DecidablePred (a < ·)] : univ.filter (a < ·) = Ioi a := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝³ : Preorder α
inst✝² : LocallyFiniteOrderTop α
a : α
inst✝¹ : Fintype α
inst✝ : DecidablePred fun x => a < x
⊢ filter (fun x => a < x) univ = Ioi a

Next tactic:
ext
theorem filter_lt_eq_Ioi [DecidablePred (a < ·)] : univ.filter (a < ·) = Ioi a := by
  ext
  

Proof state:
case a
ι : Type u_1
α : Type u_2
inst✝³ : Preorder α
inst✝² : LocallyFiniteOrderTop α
a : α
inst✝¹ : Fintype α
inst✝ : DecidablePred fun x => a < x
a✝ : α
⊢ a✝ ∈ filter (fun x => a < x) univ ↔ a✝ ∈ Ioi a

Next tactic:
simp
theorem filter_le_eq_Ici [DecidablePred (a ≤ ·)] : univ.filter (a ≤ ·) = Ici a := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝³ : Preorder α
inst✝² : LocallyFiniteOrderTop α
a : α
inst✝¹ : Fintype α
inst✝ : DecidablePred fun x => a ≤ x
⊢ filter (fun x => a ≤ x) univ = Ici a

Next tactic:
ext
theorem filter_le_eq_Ici [DecidablePred (a ≤ ·)] : univ.filter (a ≤ ·) = Ici a := by
  ext
  

Proof state:
case a
ι : Type u_1
α : Type u_2
inst✝³ : Preorder α
inst✝² : LocallyFiniteOrderTop α
a : α
inst✝¹ : Fintype α
inst✝ : DecidablePred fun x => a ≤ x
a✝ : α
⊢ a✝ ∈ filter (fun x => a ≤ x) univ ↔ a✝ ∈ Ici a

Next tactic:
simp
theorem Iio_subset_Iic_self : Iio a ⊆ Iic a := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝¹ : Preorder α
inst✝ : LocallyFiniteOrderBot α
a : α
⊢ Iio a ⊆ Iic a

Next tactic:
simpa [← coe_subset] using Set.Iio_subset_Iic_self
theorem filter_gt_eq_Iio [DecidablePred (· < a)] : univ.filter (· < a) = Iio a := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝³ : Preorder α
inst✝² : LocallyFiniteOrderBot α
a : α
inst✝¹ : Fintype α
inst✝ : DecidablePred fun x => x < a
⊢ filter (fun x => x < a) univ = Iio a

Next tactic:
ext
theorem filter_gt_eq_Iio [DecidablePred (· < a)] : univ.filter (· < a) = Iio a := by
  ext
  

Proof state:
case a
ι : Type u_1
α : Type u_2
inst✝³ : Preorder α
inst✝² : LocallyFiniteOrderBot α
a : α
inst✝¹ : Fintype α
inst✝ : DecidablePred fun x => x < a
a✝ : α
⊢ a✝ ∈ filter (fun x => x < a) univ ↔ a✝ ∈ Iio a

Next tactic:
simp
theorem filter_ge_eq_Iic [DecidablePred (· ≤ a)] : univ.filter (· ≤ a) = Iic a := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝³ : Preorder α
inst✝² : LocallyFiniteOrderBot α
a : α
inst✝¹ : Fintype α
inst✝ : DecidablePred fun x => x ≤ a
⊢ filter (fun x => x ≤ a) univ = Iic a

Next tactic:
ext
theorem filter_ge_eq_Iic [DecidablePred (· ≤ a)] : univ.filter (· ≤ a) = Iic a := by
  ext
  

Proof state:
case a
ι : Type u_1
α : Type u_2
inst✝³ : Preorder α
inst✝² : LocallyFiniteOrderBot α
a : α
inst✝¹ : Fintype α
inst✝ : DecidablePred fun x => x ≤ a
a✝ : α
⊢ a✝ ∈ filter (fun x => x ≤ a) univ ↔ a✝ ∈ Iic a

Next tactic:
simp
@[simp]
theorem Icc_self (a : α) : Icc a a = {a} := by 

Proof state:
ι : Type u_1
α : Type u_2
inst✝¹ : PartialOrder α
inst✝ : LocallyFiniteOrder α
a✝ b c a : α
⊢ Icc a a = {a}

Next tactic:
rw [← coe_eq_singleton, coe_Icc, Set.Icc_self]
@[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 α
inst✝ : LocallyFiniteOrder α
a b c : α
⊢ Icc a b = {c} ↔ a = c ∧ b = c

Next tactic:
rw [← coe_eq_singleton, coe_Icc, Set.Icc_eq_singleton_iff]
@[simp]
theorem Icc_erase_left (a b : α) : (Icc a b).erase a = Ioc a b := by 

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : PartialOrder α
inst✝¹ : LocallyFiniteOrder α
a✝ b✝ c : α
inst✝ : DecidableEq α
a b : α
⊢ erase (Icc a b) a = Ioc a b

Next tactic:
simp [← coe_inj]
@[simp]
theorem Icc_erase_right (a b : α) : (Icc a b).erase b = Ico a b := by 

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : PartialOrder α
inst✝¹ : LocallyFiniteOrder α
a✝ b✝ c : α
inst✝ : DecidableEq α
a b : α
⊢ erase (Icc a b) b = Ico a b

Next tactic:
simp [← coe_inj]
@[simp]
theorem Ico_erase_left (a b : α) : (Ico a b).erase a = Ioo a b := by 

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : PartialOrder α
inst✝¹ : LocallyFiniteOrder α
a✝ b✝ c : α
inst✝ : DecidableEq α
a b : α
⊢ erase (Ico a b) a = Ioo a b

Next tactic:
simp [← coe_inj]
@[simp]
theorem Ioc_erase_right (a b : α) : (Ioc a b).erase b = Ioo a b := by 

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : PartialOrder α
inst✝¹ : LocallyFiniteOrder α
a✝ b✝ c : α
inst✝ : DecidableEq α
a b : α
⊢ erase (Ioc a b) b = Ioo a b

Next tactic:
simp [← coe_inj]
@[simp]
theorem Icc_diff_both (a b : α) : Icc a b \ {a, b} = Ioo a b := by 

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : PartialOrder α
inst✝¹ : LocallyFiniteOrder α
a✝ b✝ c : α
inst✝ : DecidableEq α
a b : α
⊢ Icc a b \ {a, b} = Ioo a b

Next tactic:
simp [← coe_inj]
@[simp]
theorem Ico_insert_right (h : a ≤ b) : insert b (Ico a b) = Icc a b := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : PartialOrder α
inst✝¹ : LocallyFiniteOrder α
a b c : α
inst✝ : DecidableEq α
h : a ≤ b
⊢ insert b (Ico a b) = Icc a b

Next tactic:
rw [← coe_inj, coe_insert, coe_Icc, coe_Ico, Set.insert_eq, Set.union_comm, Set.Ico_union_right h]
@[simp]
theorem Ioc_insert_left (h : a ≤ b) : insert a (Ioc a b) = Icc a b := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : PartialOrder α
inst✝¹ : LocallyFiniteOrder α
a b c : α
inst✝ : DecidableEq α
h : a ≤ b
⊢ insert a (Ioc a b) = Icc a b

Next tactic:
rw [← coe_inj, coe_insert, coe_Ioc, coe_Icc, Set.insert_eq, Set.union_comm, Set.Ioc_union_left h]
@[simp]
theorem Ioo_insert_left (h : a < b) : insert a (Ioo a b) = Ico a b := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : PartialOrder α
inst✝¹ : LocallyFiniteOrder α
a b c : α
inst✝ : DecidableEq α
h : a < b
⊢ insert a (Ioo a b) = Ico a b

Next tactic:
rw [← coe_inj, coe_insert, coe_Ioo, coe_Ico, Set.insert_eq, Set.union_comm, Set.Ioo_union_left h]
@[simp]
theorem Ioo_insert_right (h : a < b) : insert b (Ioo a b) = Ioc a b := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : PartialOrder α
inst✝¹ : LocallyFiniteOrder α
a b c : α
inst✝ : DecidableEq α
h : a < b
⊢ insert b (Ioo a b) = Ioc a b

Next tactic:
rw [← coe_inj, coe_insert, coe_Ioo, coe_Ioc, Set.insert_eq, Set.union_comm, Set.Ioo_union_right h]
@[simp]
theorem Icc_diff_Ico_self (h : a ≤ b) : Icc a b \ Ico a b = {b} := by 

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : PartialOrder α
inst✝¹ : LocallyFiniteOrder α
a b c : α
inst✝ : DecidableEq α
h : a ≤ b
⊢ Icc a b \ Ico a b = {b}

Next tactic:
simp [← coe_inj, h]
@[simp]
theorem Icc_diff_Ioc_self (h : a ≤ b) : Icc a b \ Ioc a b = {a} := by 

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : PartialOrder α
inst✝¹ : LocallyFiniteOrder α
a b c : α
inst✝ : DecidableEq α
h : a ≤ b
⊢ Icc a b \ Ioc a b = {a}

Next tactic:
simp [← coe_inj, h]
@[simp]
theorem Icc_diff_Ioo_self (h : a ≤ b) : Icc a b \ Ioo a b = {a, b} := by 

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : PartialOrder α
inst✝¹ : LocallyFiniteOrder α
a b c : α
inst✝ : DecidableEq α
h : a ≤ b
⊢ Icc a b \ Ioo a b = {a, b}

Next tactic:
simp [← coe_inj, h]
@[simp]
theorem Ico_diff_Ioo_self (h : a < b) : Ico a b \ Ioo a b = {a} := by 

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : PartialOrder α
inst✝¹ : LocallyFiniteOrder α
a b c : α
inst✝ : DecidableEq α
h : a < b
⊢ Ico a b \ Ioo a b = {a}

Next tactic:
simp [← coe_inj, h]
@[simp]
theorem Ioc_diff_Ioo_self (h : a < b) : Ioc a b \ Ioo a b = {b} := by 

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : PartialOrder α
inst✝¹ : LocallyFiniteOrder α
a b c : α
inst✝ : DecidableEq α
h : a < b
⊢ Ioc a b \ Ioo a b = {b}

Next tactic:
simp [← coe_inj, h]
/-- `Finset.cons` version of `Finset.Ico_insert_right`. -/
theorem Icc_eq_cons_Ico (h : a ≤ b) : Icc a b = (Ico a b).cons b right_not_mem_Ico := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝¹ : PartialOrder α
inst✝ : LocallyFiniteOrder α
a b c : α
h : a ≤ b
⊢ Icc a b = cons b (Ico a b) (_ : b ∉ Ico a b)

Next tactic:
classical rw [cons_eq_insert, Ico_insert_right h]
/-- `Finset.cons` version of `Finset.Ico_insert_right`. -/
theorem Icc_eq_cons_Ico (h : a ≤ b) : Icc a b = (Ico a b).cons b right_not_mem_Ico := by
  classical 

Proof state:
ι : Type u_1
α : Type u_2
inst✝¹ : PartialOrder α
inst✝ : LocallyFiniteOrder α
a b c : α
h : a ≤ b
⊢ Icc a b = cons b (Ico a b) (_ : b ∉ Ico a b)

Next tactic:
rw [cons_eq_insert, Ico_insert_right h]
/-- `Finset.cons` version of `Finset.Ioc_insert_left`. -/
theorem Icc_eq_cons_Ioc (h : a ≤ b) : Icc a b = (Ioc a b).cons a left_not_mem_Ioc := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝¹ : PartialOrder α
inst✝ : LocallyFiniteOrder α
a b c : α
h : a ≤ b
⊢ Icc a b = cons a (Ioc a b) (_ : a ∉ Ioc a b)

Next tactic:
classical rw [cons_eq_insert, Ioc_insert_left h]
/-- `Finset.cons` version of `Finset.Ioc_insert_left`. -/
theorem Icc_eq_cons_Ioc (h : a ≤ b) : Icc a b = (Ioc a b).cons a left_not_mem_Ioc := by
  classical 

Proof state:
ι : Type u_1
α : Type u_2
inst✝¹ : PartialOrder α
inst✝ : LocallyFiniteOrder α
a b c : α
h : a ≤ b
⊢ Icc a b = cons a (Ioc a b) (_ : a ∉ Ioc a b)

Next tactic:
rw [cons_eq_insert, Ioc_insert_left h]
/-- `Finset.cons` version of `Finset.Ioo_insert_right`. -/
theorem Ioc_eq_cons_Ioo (h : a < b) : Ioc a b = (Ioo a b).cons b right_not_mem_Ioo := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝¹ : PartialOrder α
inst✝ : LocallyFiniteOrder α
a b c : α
h : a < b
⊢ Ioc a b = cons b (Ioo a b) (_ : b ∉ Ioo a b)

Next tactic:
classical rw [cons_eq_insert, Ioo_insert_right h]
/-- `Finset.cons` version of `Finset.Ioo_insert_right`. -/
theorem Ioc_eq_cons_Ioo (h : a < b) : Ioc a b = (Ioo a b).cons b right_not_mem_Ioo := by
  classical 

Proof state:
ι : Type u_1
α : Type u_2
inst✝¹ : PartialOrder α
inst✝ : LocallyFiniteOrder α
a b c : α
h : a < b
⊢ Ioc a b = cons b (Ioo a b) (_ : b ∉ Ioo a b)

Next tactic:
rw [cons_eq_insert, Ioo_insert_right h]
/-- `Finset.cons` version of `Finset.Ioo_insert_left`. -/
theorem Ico_eq_cons_Ioo (h : a < b) : Ico a b = (Ioo a b).cons a left_not_mem_Ioo := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝¹ : PartialOrder α
inst✝ : LocallyFiniteOrder α
a b c : α
h : a < b
⊢ Ico a b = cons a (Ioo a b) (_ : a ∉ Ioo a b)

Next tactic:
classical rw [cons_eq_insert, Ioo_insert_left h]
/-- `Finset.cons` version of `Finset.Ioo_insert_left`. -/
theorem Ico_eq_cons_Ioo (h : a < b) : Ico a b = (Ioo a b).cons a left_not_mem_Ioo := by
  classical 

Proof state:
ι : Type u_1
α : Type u_2
inst✝¹ : PartialOrder α
inst✝ : LocallyFiniteOrder α
a b c : α
h : a < b
⊢ Ico a b = cons a (Ioo a b) (_ : a ∉ Ioo a b)

Next tactic:
rw [cons_eq_insert, Ioo_insert_left h]
theorem Ico_filter_le_left {a b : α} [DecidablePred (· ≤ a)] (hab : a < b) :
    ((Ico a b).filter fun x => x ≤ a) = {a} := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : PartialOrder α
inst✝¹ : LocallyFiniteOrder α
a✝ b✝ c a b : α
inst✝ : DecidablePred fun x => x ≤ a
hab : a < b
⊢ filter (fun x => x ≤ a) (Ico a b) = {a}

Next tactic:
ext x
theorem Ico_filter_le_left {a b : α} [DecidablePred (· ≤ a)] (hab : a < b) :
    ((Ico a b).filter fun x => x ≤ a) = {a} := by
  ext x
  

Proof state:
case a
ι : Type u_1
α : Type u_2
inst✝² : PartialOrder α
inst✝¹ : LocallyFiniteOrder α
a✝ b✝ c a b : α
inst✝ : DecidablePred fun x => x ≤ a
hab : a < b
x : α
⊢ x ∈ filter (fun x => x ≤ a) (Ico a b) ↔ x ∈ {a}

Next tactic:
rw [mem_filter, mem_Ico, mem_singleton, and_right_comm, ← le_antisymm_iff, eq_comm]
theorem Ico_filter_le_left {a b : α} [DecidablePred (· ≤ a)] (hab : a < b) :
    ((Ico a b).filter fun x => x ≤ a) = {a} := by
  ext x
  rw [mem_filter, mem_Ico, mem_singleton, and_right_comm, ← le_antisymm_iff, eq_comm]
  

Proof state:
case a
ι : Type u_1
α : Type u_2
inst✝² : PartialOrder α
inst✝¹ : LocallyFiniteOrder α
a✝ b✝ c a b : α
inst✝ : DecidablePred fun x => x ≤ a
hab : a < b
x : α
⊢ x = a ∧ x < b ↔ x = a

Next tactic:
exact and_iff_left_of_imp fun h => h.le.trans_lt hab
theorem card_Ico_eq_card_Icc_sub_one (a b : α) : (Ico a b).card = (Icc a b).card - 1 := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝¹ : PartialOrder α
inst✝ : LocallyFiniteOrder α
a✝ b✝ c a b : α
⊢ card (Ico a b) = card (Icc a b) - 1

Next tactic:
classical
    by_cases h : a ≤ b
    · rw [Icc_eq_cons_Ico h, card_cons]
      exact (Nat.add_sub_cancel _ _).symm
    · rw [Ico_eq_empty fun h' => h h'.le, Icc_eq_empty h, card_empty, zero_tsub]
theorem card_Ico_eq_card_Icc_sub_one (a b : α) : (Ico a b).card = (Icc a b).card - 1 := by
  classical
    

Proof state:
ι : Type u_1
α : Type u_2
inst✝¹ : PartialOrder α
inst✝ : LocallyFiniteOrder α
a✝ b✝ c a b : α
⊢ card (Ico a b) = card (Icc a b) - 1

Next tactic:
by_cases h : a ≤ b
theorem card_Ico_eq_card_Icc_sub_one (a b : α) : (Ico a b).card = (Icc a b).card - 1 := by
  classical
    by_cases h : a ≤ b
    · 

Proof state:
case pos
ι : Type u_1
α : Type u_2
inst✝¹ : PartialOrder α
inst✝ : LocallyFiniteOrder α
a✝ b✝ c a b : α
h : a ≤ b
⊢ card (Ico a b) = card (Icc a b) - 1

Next tactic:
rw [Icc_eq_cons_Ico h, card_cons]
theorem card_Ico_eq_card_Icc_sub_one (a b : α) : (Ico a b).card = (Icc a b).card - 1 := by
  classical
    by_cases h : a ≤ b
    · rw [Icc_eq_cons_Ico h, card_cons]
      

Proof state:
case pos
ι : Type u_1
α : Type u_2
inst✝¹ : PartialOrder α
inst✝ : LocallyFiniteOrder α
a✝ b✝ c a b : α
h : a ≤ b
⊢ card (Ico a b) = card (Ico a b) + 1 - 1

Next tactic:
exact (Nat.add_sub_cancel _ _).symm
theorem card_Ico_eq_card_Icc_sub_one (a b : α) : (Ico a b).card = (Icc a b).card - 1 := by
  classical
    by_cases h : a ≤ b
    · rw [Icc_eq_cons_Ico h, card_cons]
      exact (Nat.add_sub_cancel _ _).symm
    · 

Proof state:
case neg
ι : Type u_1
α : Type u_2
inst✝¹ : PartialOrder α
inst✝ : LocallyFiniteOrder α
a✝ b✝ c a b : α
h : ¬a ≤ b
⊢ card (Ico a b) = card (Icc a b) - 1

Next tactic:
rw [Ico_eq_empty fun h' => h h'.le, Icc_eq_empty h, card_empty, zero_tsub]
theorem card_Ioo_eq_card_Ico_sub_one (a b : α) : (Ioo a b).card = (Ico a b).card - 1 := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝¹ : PartialOrder α
inst✝ : LocallyFiniteOrder α
a✝ b✝ c a b : α
⊢ card (Ioo a b) = card (Ico a b) - 1

Next tactic:
classical
    by_cases h : a < b
    · rw [Ico_eq_cons_Ioo h, card_cons]
      exact (Nat.add_sub_cancel _ _).symm
    · rw [Ioo_eq_empty h, Ico_eq_empty h, card_empty, zero_tsub]
theorem card_Ioo_eq_card_Ico_sub_one (a b : α) : (Ioo a b).card = (Ico a b).card - 1 := by
  classical
    

Proof state:
ι : Type u_1
α : Type u_2
inst✝¹ : PartialOrder α
inst✝ : LocallyFiniteOrder α
a✝ b✝ c a b : α
⊢ card (Ioo a b) = card (Ico a b) - 1

Next tactic:
by_cases h : a < b