l3lab/ntp-mathlib huggingface dataset:
theorem coe_le_maximum_iff : a ≤ l.maximum ↔ ∃ b, b ∈ l ∧ a ≤ b := by
  induction l with
  | nil => 

Proof state:
case nil
α : Type u_1
β : Type u_2
inst✝ : LinearOrder α
l : List α
a m : α
⊢ ↑a ≤ maximum [] ↔ ∃ b, b ∈ [] ∧ a ≤ b

Next tactic:
simp
theorem coe_le_maximum_iff : a ≤ l.maximum ↔ ∃ b, b ∈ l ∧ a ≤ b := by
  induction l with
  | nil => simp
  

Proof state:
case cons
α : Type u_1
β : Type u_2
inst✝ : LinearOrder α
l : List α
a m h : α
t : List α
ih : ↑a ≤ maximum t ↔ ∃ b, b ∈ t ∧ a ≤ b
⊢ ↑a ≤ maximum (h :: t) ↔ ∃ b, b ∈ h :: t ∧ a ≤ b

Next tactic:
| cons h t ih =>
    simp [maximum_cons, ih]
theorem coe_le_maximum_iff : a ≤ l.maximum ↔ ∃ b, b ∈ l ∧ a ≤ b := by
  induction l with
  | nil => simp
  | cons h t ih =>
    

Proof state:
case cons
α : Type u_1
β : Type u_2
inst✝ : LinearOrder α
l : List α
a m h : α
t : List α
ih : ↑a ≤ maximum t ↔ ∃ b, b ∈ t ∧ a ≤ b
⊢ ↑a ≤ maximum (h :: t) ↔ ∃ b, b ∈ h :: t ∧ a ≤ b

Next tactic:
simp [maximum_cons, ih]
theorem maximum_ne_bot_of_ne_nil (h : l ≠ []) : l.maximum ≠ ⊥ :=
  match l, h with | _ :: _, _ => by 

Proof state:
α : Type u_1
β : Type u_2
inst✝ : LinearOrder α
l : List α
a m : α
h : l ≠ []
head✝ : α
tail✝ : List α
x✝ : head✝ :: tail✝ ≠ []
⊢ maximum (head✝ :: tail✝) ≠ ⊥

Next tactic:
simp [maximum_cons]
theorem maximum_ne_bot_of_length_pos (h : 0 < l.length) : l.maximum ≠ ⊥ :=
  match l, h with | _ :: _, _ => by 

Proof state:
α : Type u_1
β : Type u_2
inst✝ : LinearOrder α
l : List α
a m : α
h : 0 < length l
head✝ : α
tail✝ : List α
x✝ : 0 < length (head✝ :: tail✝)
⊢ maximum (head✝ :: tail✝) ≠ ⊥

Next tactic:
simp [maximum_cons]
theorem maximum_of_length_pos_mem (h : 0 < l.length) :
    maximum_of_length_pos h ∈ l := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝ : LinearOrder α
l : List α
a m : α
h : 0 < length l
⊢ maximum_of_length_pos h ∈ l

Next tactic:
apply maximum_mem
theorem maximum_of_length_pos_mem (h : 0 < l.length) :
    maximum_of_length_pos h ∈ l := by
  apply maximum_mem
  

Proof state:
case a
α : Type u_1
β : Type u_2
inst✝ : LinearOrder α
l : List α
a m : α
h : 0 < length l
⊢ maximum l = ↑(maximum_of_length_pos h)

Next tactic:
simp only [coe_maximum_of_length_pos]
theorem le_maximum_of_length_pos_of_mem (h : a ∈ l) (w : 0 < l.length) :
    a ≤ l.maximum_of_length_pos w := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝ : LinearOrder α
l : List α
a m : α
h : a ∈ l
w : 0 < length l
⊢ a ≤ maximum_of_length_pos w

Next tactic:
simp only [le_maximum_of_length_pos_iff]
theorem le_maximum_of_length_pos_of_mem (h : a ∈ l) (w : 0 < l.length) :
    a ≤ l.maximum_of_length_pos w := by
  simp only [le_maximum_of_length_pos_iff]
  

Proof state:
α : Type u_1
β : Type u_2
inst✝ : LinearOrder α
l : List α
a m : α
h : a ∈ l
w : 0 < length l
⊢ ↑a ≤ maximum l

Next tactic:
exact le_maximum_of_mem' h
theorem getElem_le_maximum_of_length_pos (w : i < l.length) (h := (Nat.zero_lt_of_lt w)) :
    l[i] ≤ l.maximum_of_length_pos h := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝ : LinearOrder α
l : List α
a m : α
i : ℕ
w : i < length l
h : optParam (0 < length l) (_ : 0 < length l)
⊢ l[i] ≤ maximum_of_length_pos h

Next tactic:
apply le_maximum_of_length_pos_of_mem
theorem getElem_le_maximum_of_length_pos (w : i < l.length) (h := (Nat.zero_lt_of_lt w)) :
    l[i] ≤ l.maximum_of_length_pos h := by
  apply le_maximum_of_length_pos_of_mem
  

Proof state:
case h
α : Type u_1
β : Type u_2
inst✝ : LinearOrder α
l : List α
a m : α
i : ℕ
w : i < length l
h : optParam (0 < length l) (_ : 0 < length l)
⊢ l[i] ∈ l

Next tactic:
exact get_mem l i w
@[simp]
theorem foldr_max_of_ne_nil (h : l ≠ []) : ↑(l.foldr max ⊥) = l.maximum := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : OrderBot α
l : List α
h : l ≠ []
⊢ ↑(foldr max ⊥ l) = maximum l

Next tactic:
induction' l with hd tl IH
@[simp]
theorem foldr_max_of_ne_nil (h : l ≠ []) : ↑(l.foldr max ⊥) = l.maximum := by
  induction' l with hd tl IH
  · 

Proof state:
case nil
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : OrderBot α
l : List α
h : [] ≠ []
⊢ ↑(foldr max ⊥ []) = maximum []

Next tactic:
contradiction
@[simp]
theorem foldr_max_of_ne_nil (h : l ≠ []) : ↑(l.foldr max ⊥) = l.maximum := by
  induction' l with hd tl IH
  · contradiction
  · 

Proof state:
case cons
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : OrderBot α
l : List α
hd : α
tl : List α
IH : tl ≠ [] → ↑(foldr max ⊥ tl) = maximum tl
h : hd :: tl ≠ []
⊢ ↑(foldr max ⊥ (hd :: tl)) = maximum (hd :: tl)

Next tactic:
rw [maximum_cons, foldr, WithBot.coe_max]
@[simp]
theorem foldr_max_of_ne_nil (h : l ≠ []) : ↑(l.foldr max ⊥) = l.maximum := by
  induction' l with hd tl IH
  · contradiction
  · rw [maximum_cons, foldr, WithBot.coe_max]
    

Proof state:
case cons
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : OrderBot α
l : List α
hd : α
tl : List α
IH : tl ≠ [] → ↑(foldr max ⊥ tl) = maximum tl
h : hd :: tl ≠ []
⊢ max ↑hd ↑(foldr max ⊥ tl) = max (↑hd) (maximum tl)

Next tactic:
by_cases h : tl = []
@[simp]
theorem foldr_max_of_ne_nil (h : l ≠ []) : ↑(l.foldr max ⊥) = l.maximum := by
  induction' l with hd tl IH
  · contradiction
  · rw [maximum_cons, foldr, WithBot.coe_max]
    by_cases h : tl = []
    · 

Proof state:
case pos
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : OrderBot α
l : List α
hd : α
tl : List α
IH : tl ≠ [] → ↑(foldr max ⊥ tl) = maximum tl
h✝ : hd :: tl ≠ []
h : tl = []
⊢ max ↑hd ↑(foldr max ⊥ tl) = max (↑hd) (maximum tl)

Next tactic:
simp [h]
@[simp]
theorem foldr_max_of_ne_nil (h : l ≠ []) : ↑(l.foldr max ⊥) = l.maximum := by
  induction' l with hd tl IH
  · contradiction
  · rw [maximum_cons, foldr, WithBot.coe_max]
    by_cases h : tl = []
    · simp [h]
    · 

Proof state:
case neg
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : OrderBot α
l : List α
hd : α
tl : List α
IH : tl ≠ [] → ↑(foldr max ⊥ tl) = maximum tl
h✝ : hd :: tl ≠ []
h : ¬tl = []
⊢ max ↑hd ↑(foldr max ⊥ tl) = max (↑hd) (maximum tl)

Next tactic:
simp [IH h]
theorem max_le_of_forall_le (l : List α) (a : α) (h : ∀ x ∈ l, x ≤ a) : l.foldr max ⊥ ≤ a := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : OrderBot α
l✝ l : List α
a : α
h : ∀ (x : α), x ∈ l → x ≤ a
⊢ foldr max ⊥ l ≤ a

Next tactic:
induction' l with y l IH
theorem max_le_of_forall_le (l : List α) (a : α) (h : ∀ x ∈ l, x ≤ a) : l.foldr max ⊥ ≤ a := by
  induction' l with y l IH
  · 

Proof state:
case nil
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : OrderBot α
l : List α
a : α
h : ∀ (x : α), x ∈ [] → x ≤ a
⊢ foldr max ⊥ [] ≤ a

Next tactic:
simp
theorem max_le_of_forall_le (l : List α) (a : α) (h : ∀ x ∈ l, x ≤ a) : l.foldr max ⊥ ≤ a := by
  induction' l with y l IH
  · simp
  · 

Proof state:
case cons
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : OrderBot α
l✝ : List α
a y : α
l : List α
IH : (∀ (x : α), x ∈ l → x ≤ a) → foldr max ⊥ l ≤ a
h : ∀ (x : α), x ∈ y :: l → x ≤ a
⊢ foldr max ⊥ (y :: l) ≤ a

Next tactic:
simpa [h y (mem_cons_self _ _)] using IH fun x hx => h x <| mem_cons_of_mem _ hx
theorem le_max_of_le {l : List α} {a x : α} (hx : x ∈ l) (h : a ≤ x) : a ≤ l.foldr max ⊥ := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : OrderBot α
l✝ l : List α
a x : α
hx : x ∈ l
h : a ≤ x
⊢ a ≤ foldr max ⊥ l

Next tactic:
induction' l with y l IH
theorem le_max_of_le {l : List α} {a x : α} (hx : x ∈ l) (h : a ≤ x) : a ≤ l.foldr max ⊥ := by
  induction' l with y l IH
  · 

Proof state:
case nil
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : OrderBot α
l : List α
a x : α
h : a ≤ x
hx : x ∈ []
⊢ a ≤ foldr max ⊥ []

Next tactic:
exact absurd hx (not_mem_nil _)
theorem le_max_of_le {l : List α} {a x : α} (hx : x ∈ l) (h : a ≤ x) : a ≤ l.foldr max ⊥ := by
  induction' l with y l IH
  · exact absurd hx (not_mem_nil _)
  · 

Proof state:
case cons
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : OrderBot α
l✝ : List α
a x : α
h : a ≤ x
y : α
l : List α
IH : x ∈ l → a ≤ foldr max ⊥ l
hx : x ∈ y :: l
⊢ a ≤ foldr max ⊥ (y :: l)

Next tactic:
obtain hl | hl := hx
theorem le_max_of_le {l : List α} {a x : α} (hx : x ∈ l) (h : a ≤ x) : a ≤ l.foldr max ⊥ := by
  induction' l with y l IH
  · exact absurd hx (not_mem_nil _)
  · obtain hl | hl := hx
    

Proof state:
case cons.head
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : OrderBot α
l✝ : List α
a x : α
h : a ≤ x
l : List α
IH : x ∈ l → a ≤ foldr max ⊥ l
⊢ a ≤ foldr max ⊥ (x :: l)
case cons.tail
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : OrderBot α
l✝ : List α
a x : α
h : a ≤ x
y : α
l : List α
IH : x ∈ l → a ≤ foldr max ⊥ l
a✝ : Mem x l
⊢ a ≤ foldr max ⊥ (y :: l)

Next tactic:
simp only [foldr, foldr_cons]
theorem le_max_of_le {l : List α} {a x : α} (hx : x ∈ l) (h : a ≤ x) : a ≤ l.foldr max ⊥ := by
  induction' l with y l IH
  · exact absurd hx (not_mem_nil _)
  · obtain hl | hl := hx
    simp only [foldr, foldr_cons]
    · 

Proof state:
case cons.head
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : OrderBot α
l✝ : List α
a x : α
h : a ≤ x
l : List α
IH : x ∈ l → a ≤ foldr max ⊥ l
⊢ a ≤ max x (foldr max ⊥ l)

Next tactic:
exact le_max_of_le_left h
theorem le_max_of_le {l : List α} {a x : α} (hx : x ∈ l) (h : a ≤ x) : a ≤ l.foldr max ⊥ := by
  induction' l with y l IH
  · exact absurd hx (not_mem_nil _)
  · obtain hl | hl := hx
    simp only [foldr, foldr_cons]
    · exact le_max_of_le_left h
    · 

Proof state:
case cons.tail
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : OrderBot α
l✝ : List α
a x : α
h : a ≤ x
y : α
l : List α
IH : x ∈ l → a ≤ foldr max ⊥ l
a✝ : Mem x l
⊢ a ≤ foldr max ⊥ (y :: l)

Next tactic:
exact le_max_of_le_right (IH (by assumption))
theorem le_max_of_le {l : List α} {a x : α} (hx : x ∈ l) (h : a ≤ x) : a ≤ l.foldr max ⊥ := by
  induction' l with y l IH
  · exact absurd hx (not_mem_nil _)
  · obtain hl | hl := hx
    simp only [foldr, foldr_cons]
    · exact le_max_of_le_left h
    · exact le_max_of_le_right (IH (by 

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : OrderBot α
l✝ : List α
a x : α
h : a ≤ x
y : α
l : List α
IH : x ∈ l → a ≤ foldr max ⊥ l
a✝ : Mem x l
⊢ x ∈ l

Next tactic:
assumption
@[simp]
theorem isUpperSet_compl : IsUpperSet sᶜ ↔ IsLowerSet s :=
  ⟨fun h => by
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝¹ : LE α
inst✝ : LE β
s t : Set α
a : α
h : IsUpperSet sᶜ
⊢ IsLowerSet s

Next tactic:
convert h.compl
@[simp]
theorem isUpperSet_compl : IsUpperSet sᶜ ↔ IsLowerSet s :=
  ⟨fun h => by
    convert h.compl
    

Proof state:
case h.e'_3
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝¹ : LE α
inst✝ : LE β
s t : Set α
a : α
h : IsUpperSet sᶜ
⊢ s = sᶜᶜ

Next tactic:
rw [compl_compl]
@[simp]
theorem isLowerSet_compl : IsLowerSet sᶜ ↔ IsUpperSet s :=
  ⟨fun h => by
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝¹ : LE α
inst✝ : LE β
s t : Set α
a : α
h : IsLowerSet sᶜ
⊢ IsUpperSet s

Next tactic:
convert h.compl
@[simp]
theorem isLowerSet_compl : IsLowerSet sᶜ ↔ IsUpperSet s :=
  ⟨fun h => by
    convert h.compl
    

Proof state:
case h.e'_3
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝¹ : LE α
inst✝ : LE β
s t : Set α
a : α
h : IsLowerSet sᶜ
⊢ s = sᶜᶜ

Next tactic:
rw [compl_compl]
lemma IsUpperSet.isLowerSet_preimage_coe (hs : IsUpperSet s) :
    IsLowerSet ((↑) ⁻¹' t : Set s) ↔ ∀ b ∈ s, ∀ c ∈ t, b ≤ c → b ∈ t := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝¹ : LE α
inst✝ : LE β
s t : Set α
a : α
hs : IsUpperSet s
⊢ IsLowerSet (Subtype.val ⁻¹' t) ↔ ∀ b ∈ s, ∀ c ∈ t, b ≤ c → b ∈ t

Next tactic:
aesop
lemma IsLowerSet.isUpperSet_preimage_coe (hs : IsLowerSet s) :
    IsUpperSet ((↑) ⁻¹' t : Set s) ↔ ∀ b ∈ s, ∀ c ∈ t, c ≤ b → b ∈ t := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝¹ : LE α
inst✝ : LE β
s t : Set α
a : α
hs : IsLowerSet s
⊢ IsUpperSet (Subtype.val ⁻¹' t) ↔ ∀ b ∈ s, ∀ c ∈ t, c ≤ b → b ∈ t

Next tactic:
aesop
lemma IsUpperSet.sdiff_of_isLowerSet (hs : IsUpperSet s) (ht : IsLowerSet t) : IsUpperSet (s \ t) :=
  hs.sdiff $ by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝¹ : LE α
inst✝ : LE β
s t : Set α
a : α
hs : IsUpperSet s
ht : IsLowerSet t
⊢ ∀ b ∈ s, ∀ c ∈ t, b ≤ c → b ∈ t

Next tactic:
aesop
lemma IsLowerSet.sdiff_of_isUpperSet (hs : IsLowerSet s) (ht : IsUpperSet t) : IsLowerSet (s \ t) :=
  hs.sdiff $ by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝¹ : LE α
inst✝ : LE β
s t : Set α
a : α
hs : IsLowerSet s
ht : IsUpperSet t
⊢ ∀ b ∈ s, ∀ c ∈ t, c ≤ b → b ∈ t

Next tactic:
aesop
lemma IsUpperSet.erase (hs : IsUpperSet s) (has : ∀ b ∈ s, b ≤ a → b = a) : IsUpperSet (s \ {a}) :=
  hs.sdiff $ by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝¹ : LE α
inst✝ : LE β
s t : Set α
a : α
hs : IsUpperSet s
has : ∀ b ∈ s, b ≤ a → b = a
⊢ ∀ b ∈ s, ∀ c ∈ {a}, b ≤ c → b ∈ {a}

Next tactic:
simpa using has
lemma IsLowerSet.erase (hs : IsLowerSet s) (has : ∀ b ∈ s, a ≤ b → b = a) : IsLowerSet (s \ {a}) :=
  hs.sdiff $ by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝¹ : LE α
inst✝ : LE β
s t : Set α
a : α
hs : IsLowerSet s
has : ∀ b ∈ s, a ≤ b → b = a
⊢ ∀ b ∈ s, ∀ c ∈ {a}, c ≤ b → b ∈ {a}

Next tactic:
simpa using has
theorem isUpperSet_iff_Ici_subset : IsUpperSet s ↔ ∀ ⦃a⦄, a ∈ s → Ici a ⊆ s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝¹ : Preorder α
inst✝ : Preorder β
s : Set α
p : α → Prop
a : α
⊢ IsUpperSet s ↔ ∀ ⦃a : α⦄, a ∈ s → Ici a ⊆ s

Next tactic:
simp [IsUpperSet, subset_def, @forall_swap (_ ∈ s)]
theorem isLowerSet_iff_Iic_subset : IsLowerSet s ↔ ∀ ⦃a⦄, a ∈ s → Iic a ⊆ s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝¹ : Preorder α
inst✝ : Preorder β
s : Set α
p : α → Prop
a : α
⊢ IsLowerSet s ↔ ∀ ⦃a : α⦄, a ∈ s → Iic a ⊆ s

Next tactic:
simp [IsLowerSet, subset_def, @forall_swap (_ ∈ s)]
theorem IsUpperSet.image (hs : IsUpperSet s) (f : α ≃o β) : IsUpperSet (f '' s : Set β) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝¹ : Preorder α
inst✝ : Preorder β
s : Set α
p : α → Prop
a : α
hs : IsUpperSet s
f : α ≃o β
⊢ IsUpperSet (⇑f '' s)

Next tactic:
change IsUpperSet ((f : α ≃ β) '' s)
theorem IsUpperSet.image (hs : IsUpperSet s) (f : α ≃o β) : IsUpperSet (f '' s : Set β) := by
  change IsUpperSet ((f : α ≃ β) '' s)
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝¹ : Preorder α
inst✝ : Preorder β
s : Set α
p : α → Prop
a : α
hs : IsUpperSet s
f : α ≃o β
⊢ IsUpperSet (⇑↑f '' s)

Next tactic:
rw [Set.image_equiv_eq_preimage_symm]
theorem IsUpperSet.image (hs : IsUpperSet s) (f : α ≃o β) : IsUpperSet (f '' s : Set β) := by
  change IsUpperSet ((f : α ≃ β) '' s)
  rw [Set.image_equiv_eq_preimage_symm]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝¹ : Preorder α
inst✝ : Preorder β
s : Set α
p : α → Prop
a : α
hs : IsUpperSet s
f : α ≃o β
⊢ IsUpperSet (⇑(↑f).symm ⁻¹' s)

Next tactic:
exact hs.preimage f.symm.monotone
theorem IsLowerSet.image (hs : IsLowerSet s) (f : α ≃o β) : IsLowerSet (f '' s : Set β) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝¹ : Preorder α
inst✝ : Preorder β
s : Set α
p : α → Prop
a : α
hs : IsLowerSet s
f : α ≃o β
⊢ IsLowerSet (⇑f '' s)

Next tactic:
change IsLowerSet ((f : α ≃ β) '' s)
theorem IsLowerSet.image (hs : IsLowerSet s) (f : α ≃o β) : IsLowerSet (f '' s : Set β) := by
  change IsLowerSet ((f : α ≃ β) '' s)
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝¹ : Preorder α
inst✝ : Preorder β
s : Set α
p : α → Prop
a : α
hs : IsLowerSet s
f : α ≃o β
⊢ IsLowerSet (⇑↑f '' s)

Next tactic:
rw [Set.image_equiv_eq_preimage_symm]
theorem IsLowerSet.image (hs : IsLowerSet s) (f : α ≃o β) : IsLowerSet (f '' s : Set β) := by
  change IsLowerSet ((f : α ≃ β) '' s)
  rw [Set.image_equiv_eq_preimage_symm]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝¹ : Preorder α
inst✝ : Preorder β
s : Set α
p : α → Prop
a : α
hs : IsLowerSet s
f : α ≃o β
⊢ IsLowerSet (⇑(↑f).symm ⁻¹' s)

Next tactic:
exact hs.preimage f.symm.monotone
theorem IsUpperSet.not_bddAbove (hs : IsUpperSet s) : s.Nonempty → ¬BddAbove s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝² : Preorder α
inst✝¹ : Preorder β
s : Set α
p : α → Prop
a : α
inst✝ : NoMaxOrder α
hs : IsUpperSet s
⊢ Set.Nonempty s → ¬BddAbove s

Next tactic:
rintro ⟨a, ha⟩ ⟨b, hb⟩
theorem IsUpperSet.not_bddAbove (hs : IsUpperSet s) : s.Nonempty → ¬BddAbove s := by
  rintro ⟨a, ha⟩ ⟨b, hb⟩
  

Proof state:
case intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝² : Preorder α
inst✝¹ : Preorder β
s : Set α
p : α → Prop
a✝ : α
inst✝ : NoMaxOrder α
hs : IsUpperSet s
a : α
ha : a ∈ s
b : α
hb : b ∈ upperBounds s
⊢ False

Next tactic:
obtain ⟨c, hc⟩ := exists_gt b
theorem IsUpperSet.not_bddAbove (hs : IsUpperSet s) : s.Nonempty → ¬BddAbove s := by
  rintro ⟨a, ha⟩ ⟨b, hb⟩
  obtain ⟨c, hc⟩ := exists_gt b
  

Proof state:
case intro.intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝² : Preorder α
inst✝¹ : Preorder β
s : Set α
p : α → Prop
a✝ : α
inst✝ : NoMaxOrder α
hs : IsUpperSet s
a : α
ha : a ∈ s
b : α
hb : b ∈ upperBounds s
c : α
hc : b < c
⊢ False

Next tactic:
exact hc.not_le (hb <| hs ((hb ha).trans hc.le) ha)
theorem IsLowerSet.not_bddBelow (hs : IsLowerSet s) : s.Nonempty → ¬BddBelow s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝² : Preorder α
inst✝¹ : Preorder β
s : Set α
p : α → Prop
a : α
inst✝ : NoMinOrder α
hs : IsLowerSet s
⊢ Set.Nonempty s → ¬BddBelow s

Next tactic:
rintro ⟨a, ha⟩ ⟨b, hb⟩
theorem IsLowerSet.not_bddBelow (hs : IsLowerSet s) : s.Nonempty → ¬BddBelow s := by
  rintro ⟨a, ha⟩ ⟨b, hb⟩
  

Proof state:
case intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝² : Preorder α
inst✝¹ : Preorder β
s : Set α
p : α → Prop
a✝ : α
inst✝ : NoMinOrder α
hs : IsLowerSet s
a : α
ha : a ∈ s
b : α
hb : b ∈ lowerBounds s
⊢ False

Next tactic:
obtain ⟨c, hc⟩ := exists_lt b
theorem IsLowerSet.not_bddBelow (hs : IsLowerSet s) : s.Nonempty → ¬BddBelow s := by
  rintro ⟨a, ha⟩ ⟨b, hb⟩
  obtain ⟨c, hc⟩ := exists_lt b
  

Proof state:
case intro.intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝² : Preorder α
inst✝¹ : Preorder β
s : Set α
p : α → Prop
a✝ : α
inst✝ : NoMinOrder α
hs : IsLowerSet s
a : α
ha : a ∈ s
b : α
hb : b ∈ lowerBounds s
c : α
hc : c < b
⊢ False

Next tactic:
exact hc.not_le (hb <| hs (hc.le.trans <| hb ha) ha)
theorem isUpperSet_iff_forall_lt : IsUpperSet s ↔ ∀ ⦃a b : α⦄, a < b → a ∈ s → b ∈ s :=
  forall_congr' fun a => by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝ : PartialOrder α
s : Set α
a : α
⊢ (∀ ⦃b : α⦄, a ≤ b → a ∈ s → b ∈ s) ↔ ∀ ⦃b : α⦄, a < b → a ∈ s → b ∈ s

Next tactic:
simp [le_iff_eq_or_lt, or_imp, forall_and]
theorem isLowerSet_iff_forall_lt : IsLowerSet s ↔ ∀ ⦃a b : α⦄, b < a → a ∈ s → b ∈ s :=
  forall_congr' fun a => by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝ : PartialOrder α
s : Set α
a : α
⊢ (∀ ⦃b : α⦄, b ≤ a → a ∈ s → b ∈ s) ↔ ∀ ⦃b : α⦄, b < a → a ∈ s → b ∈ s

Next tactic:
simp [le_iff_eq_or_lt, or_imp, forall_and]
theorem isUpperSet_iff_Ioi_subset : IsUpperSet s ↔ ∀ ⦃a⦄, a ∈ s → Ioi a ⊆ s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝ : PartialOrder α
s : Set α
⊢ IsUpperSet s ↔ ∀ ⦃a : α⦄, a ∈ s → Ioi a ⊆ s

Next tactic:
simp [isUpperSet_iff_forall_lt, subset_def, @forall_swap (_ ∈ s)]
theorem isLowerSet_iff_Iio_subset : IsLowerSet s ↔ ∀ ⦃a⦄, a ∈ s → Iio a ⊆ s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝ : PartialOrder α
s : Set α
⊢ IsLowerSet s ↔ ∀ ⦃a : α⦄, a ∈ s → Iio a ⊆ s

Next tactic:
simp [isLowerSet_iff_forall_lt, subset_def, @forall_swap (_ ∈ s)]
theorem IsUpperSet.total (hs : IsUpperSet s) (ht : IsUpperSet t) : s ⊆ t ∨ t ⊆ s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝ : LinearOrder α
s t : Set α
hs : IsUpperSet s
ht : IsUpperSet t
⊢ s ⊆ t ∨ t ⊆ s

Next tactic:
by_contra! h
theorem IsUpperSet.total (hs : IsUpperSet s) (ht : IsUpperSet t) : s ⊆ t ∨ t ⊆ s := by
  by_contra! h
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝ : LinearOrder α
s t : Set α
hs : IsUpperSet s
ht : IsUpperSet t
h : ¬s ⊆ t ∧ ¬t ⊆ s
⊢ False

Next tactic:
simp_rw [Set.not_subset] at h
theorem IsUpperSet.total (hs : IsUpperSet s) (ht : IsUpperSet t) : s ⊆ t ∨ t ⊆ s := by
  by_contra! h
  simp_rw [Set.not_subset] at h
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝ : LinearOrder α
s t : Set α
hs : IsUpperSet s
ht : IsUpperSet t
h : (∃ a ∈ s, a ∉ t) ∧ ∃ a ∈ t, a ∉ s
⊢ False

Next tactic:
obtain ⟨⟨a, has, hat⟩, b, hbt, hbs⟩ := h
theorem IsUpperSet.total (hs : IsUpperSet s) (ht : IsUpperSet t) : s ⊆ t ∨ t ⊆ s := by
  by_contra! h
  simp_rw [Set.not_subset] at h
  obtain ⟨⟨a, has, hat⟩, b, hbt, hbs⟩ := h
  

Proof state:
case intro.intro.intro.intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝ : LinearOrder α
s t : Set α
hs : IsUpperSet s
ht : IsUpperSet t
a : α
has : a ∈ s
hat : a ∉ t
b : α
hbt : b ∈ t
hbs : b ∉ s
⊢ False

Next tactic:
obtain hab | hba := le_total a b
theorem IsUpperSet.total (hs : IsUpperSet s) (ht : IsUpperSet t) : s ⊆ t ∨ t ⊆ s := by
  by_contra! h
  simp_rw [Set.not_subset] at h
  obtain ⟨⟨a, has, hat⟩, b, hbt, hbs⟩ := h
  obtain hab | hba := le_total a b
  · 

Proof state:
case intro.intro.intro.intro.intro.inl
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝ : LinearOrder α
s t : Set α
hs : IsUpperSet s
ht : IsUpperSet t
a : α
has : a ∈ s
hat : a ∉ t
b : α
hbt : b ∈ t
hbs : b ∉ s
hab : a ≤ b
⊢ False

Next tactic:
exact hbs (hs hab has)
theorem IsUpperSet.total (hs : IsUpperSet s) (ht : IsUpperSet t) : s ⊆ t ∨ t ⊆ s := by
  by_contra! h
  simp_rw [Set.not_subset] at h
  obtain ⟨⟨a, has, hat⟩, b, hbt, hbs⟩ := h
  obtain hab | hba := le_total a b
  · exact hbs (hs hab has)
  · 

Proof state:
case intro.intro.intro.intro.intro.inr
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝ : LinearOrder α
s t : Set α
hs : IsUpperSet s
ht : IsUpperSet t
a : α
has : a ∈ s
hat : a ∉ t
b : α
hbt : b ∈ t
hbs : b ∉ s
hba : b ≤ a
⊢ False

Next tactic:
exact hat (ht hba hbt)
instance : SetLike (UpperSet α) α where
  coe := UpperSet.carrier
  coe_injective' s t h := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝ : LE α
s t : UpperSet α
h : s.carrier = t.carrier
⊢ s = t

Next tactic:
cases s
instance : SetLike (UpperSet α) α where
  coe := UpperSet.carrier
  coe_injective' s t h := by cases s; 

Proof state:
case mk
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝ : LE α
t : UpperSet α
carrier✝ : Set α
upper'✝ : IsUpperSet carrier✝
h : { carrier := carrier✝, upper' := upper'✝ }.carrier = t.carrier
⊢ { carrier := carrier✝, upper' := upper'✝ } = t

Next tactic:
cases t
instance : SetLike (UpperSet α) α where
  coe := UpperSet.carrier
  coe_injective' s t h := by cases s; cases t; 

Proof state:
case mk.mk
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Sort u_4
κ : ι → Sort u_5
inst✝ : LE α
carrier✝¹ : Set α
upper'✝¹ : IsUpperSet carrier✝¹
carrier✝ : Set α
upper'✝ : IsUpperSet carrier✝
h : { carrier := carrier✝¹, upper' := upper'✝¹ }.carrier = { carrier := carrier✝, upper' := upper'✝ }.carrier
⊢ { carrier := carrier✝¹, upper' := upper'✝¹ } = { carrier := carrier✝, upper' := upper'✝ }

Next tactic:
congr