l3lab/ntp-mathlib huggingface dataset:
theorem max_of_mem {s : Finset α} {a : α} (h : a ∈ s) : ∃ b : α, s.max = b := by
  obtain ⟨b, h, _⟩ := le_sup (α := WithBot α) h _ rfl
  

Proof state:
case intro.intro
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s : Finset α
a : α
h✝ : a ∈ s
b : α
h : b ∈ sup s some
right✝ : a ≤ b
⊢ ∃ b, Finset.max s = ↑b

Next tactic:
exact ⟨b, h⟩
theorem max_eq_bot {s : Finset α} : s.max = ⊥ ↔ s = ∅ :=
  ⟨fun h ↦ s.eq_empty_or_nonempty.elim id fun H ↦ by
      

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s : Finset α
h : Finset.max s = ⊥
H : Finset.Nonempty s
⊢ s = ∅

Next tactic:
obtain ⟨a, ha⟩ := max_of_nonempty H
theorem max_eq_bot {s : Finset α} : s.max = ⊥ ↔ s = ∅ :=
  ⟨fun h ↦ s.eq_empty_or_nonempty.elim id fun H ↦ by
      obtain ⟨a, ha⟩ := max_of_nonempty H
      

Proof state:
case intro
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s : Finset α
h : Finset.max s = ⊥
H : Finset.Nonempty s
a : α
ha : Finset.max s = ↑a
⊢ s = ∅

Next tactic:
rw [h] at ha
theorem max_eq_bot {s : Finset α} : s.max = ⊥ ↔ s = ∅ :=
  ⟨fun h ↦ s.eq_empty_or_nonempty.elim id fun H ↦ by
      obtain ⟨a, ha⟩ := max_of_nonempty H
      rw [h] at ha; 

Proof state:
case intro
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s : Finset α
h : Finset.max s = ⊥
H : Finset.Nonempty s
a : α
ha : ⊥ = ↑a
⊢ s = ∅

Next tactic:
cases ha
theorem max_eq_bot {s : Finset α} : s.max = ⊥ ↔ s = ∅ :=
  ⟨fun h ↦ s.eq_empty_or_nonempty.elim id fun H ↦ by
      obtain ⟨a, ha⟩ := max_of_nonempty H
      rw [h] at ha; cases ha; 

Proof state:

Next tactic:
done
theorem mem_of_max {s : Finset α} : ∀ {a : α}, s.max = a → a ∈ s := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s : Finset α
⊢ ∀ {a : α}, Finset.max s = ↑a → a ∈ s

Next tactic:
induction' s using Finset.induction_on with b s _ ih
theorem mem_of_max {s : Finset α} : ∀ {a : α}, s.max = a → a ∈ s := by
  induction' s using Finset.induction_on with b s _ ih
  · 

Proof state:
case empty
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
⊢ ∀ {a : α}, Finset.max ∅ = ↑a → a ∈ ∅

Next tactic:
intro _ H
theorem mem_of_max {s : Finset α} : ∀ {a : α}, s.max = a → a ∈ s := by
  induction' s using Finset.induction_on with b s _ ih
  · intro _ H; 

Proof state:
case empty
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
a✝ : α
H : Finset.max ∅ = ↑a✝
⊢ a✝ ∈ ∅

Next tactic:
cases H
theorem mem_of_max {s : Finset α} : ∀ {a : α}, s.max = a → a ∈ s := by
  induction' s using Finset.induction_on with b s _ ih
  · intro _ H; cases H
  · 

Proof state:
case insert
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
b : α
s : Finset α
a✝ : b ∉ s
ih : ∀ {a : α}, Finset.max s = ↑a → a ∈ s
⊢ ∀ {a : α}, Finset.max (insert b s) = ↑a → a ∈ insert b s

Next tactic:
intro a h
theorem mem_of_max {s : Finset α} : ∀ {a : α}, s.max = a → a ∈ s := by
  induction' s using Finset.induction_on with b s _ ih
  · intro _ H; cases H
  · intro a h
    

Proof state:
case insert
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
b : α
s : Finset α
a✝ : b ∉ s
ih : ∀ {a : α}, Finset.max s = ↑a → a ∈ s
a : α
h : Finset.max (insert b s) = ↑a
⊢ a ∈ insert b s

Next tactic:
by_cases p : b = a
theorem mem_of_max {s : Finset α} : ∀ {a : α}, s.max = a → a ∈ s := by
  induction' s using Finset.induction_on with b s _ ih
  · intro _ H; cases H
  · intro a h
    by_cases p : b = a
    · 

Proof state:
case pos
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
b : α
s : Finset α
a✝ : b ∉ s
ih : ∀ {a : α}, Finset.max s = ↑a → a ∈ s
a : α
h : Finset.max (insert b s) = ↑a
p : b = a
⊢ a ∈ insert b s

Next tactic:
induction p
theorem mem_of_max {s : Finset α} : ∀ {a : α}, s.max = a → a ∈ s := by
  induction' s using Finset.induction_on with b s _ ih
  · intro _ H; cases H
  · intro a h
    by_cases p : b = a
    · induction p
      

Proof state:
case pos.refl
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
b : α
s : Finset α
a✝ : b ∉ s
ih : ∀ {a : α}, Finset.max s = ↑a → a ∈ s
a : α
h : Finset.max (insert b s) = ↑b
⊢ b ∈ insert b s

Next tactic:
exact mem_insert_self b s
theorem mem_of_max {s : Finset α} : ∀ {a : α}, s.max = a → a ∈ s := by
  induction' s using Finset.induction_on with b s _ ih
  · intro _ H; cases H
  · intro a h
    by_cases p : b = a
    · induction p
      exact mem_insert_self b s
    · 

Proof state:
case neg
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
b : α
s : Finset α
a✝ : b ∉ s
ih : ∀ {a : α}, Finset.max s = ↑a → a ∈ s
a : α
h : Finset.max (insert b s) = ↑a
p : ¬b = a
⊢ a ∈ insert b s

Next tactic:
cases' max_choice (↑b) s.max with q q
theorem mem_of_max {s : Finset α} : ∀ {a : α}, s.max = a → a ∈ s := by
  induction' s using Finset.induction_on with b s _ ih
  · intro _ H; cases H
  · intro a h
    by_cases p : b = a
    · induction p
      exact mem_insert_self b s
    · cases' max_choice (↑b) s.max with q q <;> 

Proof state:
case neg.inl
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
b : α
s : Finset α
a✝ : b ∉ s
ih : ∀ {a : α}, Finset.max s = ↑a → a ∈ s
a : α
h : Finset.max (insert b s) = ↑a
p : ¬b = a
q : max (↑b) (Finset.max s) = ↑b
⊢ a ∈ insert b s

Next tactic:
rw [max_insert, q] at h
theorem mem_of_max {s : Finset α} : ∀ {a : α}, s.max = a → a ∈ s := by
  induction' s using Finset.induction_on with b s _ ih
  · intro _ H; cases H
  · intro a h
    by_cases p : b = a
    · induction p
      exact mem_insert_self b s
    · cases' max_choice (↑b) s.max with q q <;> 

Proof state:
case neg.inr
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
b : α
s : Finset α
a✝ : b ∉ s
ih : ∀ {a : α}, Finset.max s = ↑a → a ∈ s
a : α
h : Finset.max (insert b s) = ↑a
p : ¬b = a
q : max (↑b) (Finset.max s) = Finset.max s
⊢ a ∈ insert b s

Next tactic:
rw [max_insert, q] at h
theorem mem_of_max {s : Finset α} : ∀ {a : α}, s.max = a → a ∈ s := by
  induction' s using Finset.induction_on with b s _ ih
  · intro _ H; cases H
  · intro a h
    by_cases p : b = a
    · induction p
      exact mem_insert_self b s
    · cases' max_choice (↑b) s.max with q q <;> rw [max_insert, q] at h
      · 

Proof state:
case neg.inl
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
b : α
s : Finset α
a✝ : b ∉ s
ih : ∀ {a : α}, Finset.max s = ↑a → a ∈ s
a : α
h : ↑b = ↑a
p : ¬b = a
q : max (↑b) (Finset.max s) = ↑b
⊢ a ∈ insert b s

Next tactic:
cases h
theorem mem_of_max {s : Finset α} : ∀ {a : α}, s.max = a → a ∈ s := by
  induction' s using Finset.induction_on with b s _ ih
  · intro _ H; cases H
  · intro a h
    by_cases p : b = a
    · induction p
      exact mem_insert_self b s
    · cases' max_choice (↑b) s.max with q q <;> rw [max_insert, q] at h
      · cases h
        

Proof state:
case neg.inl.refl
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
b : α
s : Finset α
a✝ : b ∉ s
ih : ∀ {a : α}, Finset.max s = ↑a → a ∈ s
q : max (↑b) (Finset.max s) = ↑b
p : ¬b = b
⊢ b ∈ insert b s

Next tactic:
cases p rfl
theorem mem_of_max {s : Finset α} : ∀ {a : α}, s.max = a → a ∈ s := by
  induction' s using Finset.induction_on with b s _ ih
  · intro _ H; cases H
  · intro a h
    by_cases p : b = a
    · induction p
      exact mem_insert_self b s
    · cases' max_choice (↑b) s.max with q q <;> rw [max_insert, q] at h
      · cases h
        cases p rfl
      · 

Proof state:
case neg.inr
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
b : α
s : Finset α
a✝ : b ∉ s
ih : ∀ {a : α}, Finset.max s = ↑a → a ∈ s
a : α
h : Finset.max s = ↑a
p : ¬b = a
q : max (↑b) (Finset.max s) = Finset.max s
⊢ a ∈ insert b s

Next tactic:
exact mem_insert_of_mem (ih h)
@[simp]
theorem min_singleton {a : α} : Finset.min {a} = (a : WithTop α) := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
a : α
⊢ Finset.min {a} = ↑a

Next tactic:
rw [← insert_emptyc_eq]
@[simp]
theorem min_singleton {a : α} : Finset.min {a} = (a : WithTop α) := by
  rw [← insert_emptyc_eq]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
a : α
⊢ Finset.min (insert a ∅) = ↑a

Next tactic:
exact min_insert
theorem min_of_mem {s : Finset α} {a : α} (h : a ∈ s) : ∃ b : α, s.min = b := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s : Finset α
a : α
h : a ∈ s
⊢ ∃ b, Finset.min s = ↑b

Next tactic:
obtain ⟨b, h, _⟩ := inf_le (α := WithTop α) h _ rfl
theorem min_of_mem {s : Finset α} {a : α} (h : a ∈ s) : ∃ b : α, s.min = b := by
  obtain ⟨b, h, _⟩ := inf_le (α := WithTop α) h _ rfl
  

Proof state:
case intro.intro
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s : Finset α
a : α
h✝ : a ∈ s
b : α
h : b ∈ inf s some
right✝ : b ≤ a
⊢ ∃ b, Finset.min s = ↑b

Next tactic:
exact ⟨b, h⟩
theorem min_eq_top {s : Finset α} : s.min = ⊤ ↔ s = ∅ :=
  ⟨fun h =>
    s.eq_empty_or_nonempty.elim id fun H => by
      

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s : Finset α
h : Finset.min s = ⊤
H : Finset.Nonempty s
⊢ s = ∅

Next tactic:
let ⟨a, ha⟩ := min_of_nonempty H
theorem min_eq_top {s : Finset α} : s.min = ⊤ ↔ s = ∅ :=
  ⟨fun h =>
    s.eq_empty_or_nonempty.elim id fun H => by
      let ⟨a, ha⟩ := min_of_nonempty H
      

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s : Finset α
h : Finset.min s = ⊤
H : Finset.Nonempty s
a : α
ha : Finset.min s = ↑a
⊢ s = ∅

Next tactic:
rw [h] at ha
theorem min_eq_top {s : Finset α} : s.min = ⊤ ↔ s = ∅ :=
  ⟨fun h =>
    s.eq_empty_or_nonempty.elim id fun H => by
      let ⟨a, ha⟩ := min_of_nonempty H
      rw [h] at ha; 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s : Finset α
h : Finset.min s = ⊤
H : Finset.Nonempty s
a : α
ha : ⊤ = ↑a
⊢ s = ∅

Next tactic:
cases ha
theorem min_eq_top {s : Finset α} : s.min = ⊤ ↔ s = ∅ :=
  ⟨fun h =>
    s.eq_empty_or_nonempty.elim id fun H => by
      let ⟨a, ha⟩ := min_of_nonempty H
      rw [h] at ha; cases ha; 

Proof state:

Next tactic:
done
theorem min'_mem : s.min' H ∈ s :=
  mem_of_min <| by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s : Finset α
H : Finset.Nonempty s
x : α
⊢ Finset.min s = ↑(min' s H)

Next tactic:
simp only [Finset.min, min', id_eq, coe_inf']
theorem min'_mem : s.min' H ∈ s :=
  mem_of_min <| by simp only [Finset.min, min', id_eq, coe_inf']; 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s : Finset α
H : Finset.Nonempty s
x : α
⊢ inf s WithTop.some = inf s (WithTop.some ∘ fun x => x)

Next tactic:
rfl
/-- `{a}.min' _` is `a`. -/
@[simp]
theorem min'_singleton (a : α) : ({a} : Finset α).min' (singleton_nonempty _) = a := by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s : Finset α
H : Finset.Nonempty s
x a : α
⊢ min' {a} (_ : Finset.Nonempty {a}) = a

Next tactic:
simp [min']
theorem max'_mem : s.max' H ∈ s :=
  mem_of_max <| by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s : Finset α
H : Finset.Nonempty s
x : α
⊢ Finset.max s = ↑(max' s H)

Next tactic:
simp only [max', Finset.max, id_eq, coe_sup']
theorem max'_mem : s.max' H ∈ s :=
  mem_of_max <| by simp only [max', Finset.max, id_eq, coe_sup']; 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s : Finset α
H : Finset.Nonempty s
x : α
⊢ sup s WithBot.some = sup s (WithBot.some ∘ fun x => x)

Next tactic:
rfl
/-- `{a}.max' _` is `a`. -/
@[simp]
theorem max'_singleton (a : α) : ({a} : Finset α).max' (singleton_nonempty _) = a := by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s : Finset α
H : Finset.Nonempty s
x a : α
⊢ max' {a} (_ : Finset.Nonempty {a}) = a

Next tactic:
simp [max']
/-- If there's more than 1 element, the min' is less than the max'. An alternate version of
`min'_lt_max'` which is sometimes more convenient.
-/
theorem min'_lt_max'_of_card (h₂ : 1 < card s) :
    s.min' (Finset.card_pos.mp <| lt_trans zero_lt_one h₂) <
      s.max' (Finset.card_pos.mp <| lt_trans zero_lt_one h₂) := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s : Finset α
H : Finset.Nonempty s
x : α
h₂ : 1 < card s
⊢ min' s (_ : Finset.Nonempty s) < max' s (_ : Finset.Nonempty s)

Next tactic:
rcases one_lt_card.1 h₂ with ⟨a, ha, b, hb, hab⟩
/-- If there's more than 1 element, the min' is less than the max'. An alternate version of
`min'_lt_max'` which is sometimes more convenient.
-/
theorem min'_lt_max'_of_card (h₂ : 1 < card s) :
    s.min' (Finset.card_pos.mp <| lt_trans zero_lt_one h₂) <
      s.max' (Finset.card_pos.mp <| lt_trans zero_lt_one h₂) := by
  rcases one_lt_card.1 h₂ with ⟨a, ha, b, hb, hab⟩
  

Proof state:
case intro.intro.intro.intro
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s : Finset α
H : Finset.Nonempty s
x : α
h₂ : 1 < card s
a : α
ha : a ∈ s
b : α
hb : b ∈ s
hab : a ≠ b
⊢ min' s (_ : Finset.Nonempty s) < max' s (_ : Finset.Nonempty s)

Next tactic:
exact s.min'_lt_max' ha hb hab
theorem map_ofDual_min (s : Finset αᵒᵈ) : s.min.map ofDual = (s.image ofDual).max := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset αᵒᵈ
⊢ WithTop.map (⇑ofDual) (Finset.min s) = Finset.max (image (⇑ofDual) s)

Next tactic:
rw [max_eq_sup_withBot, sup_image]
theorem map_ofDual_min (s : Finset αᵒᵈ) : s.min.map ofDual = (s.image ofDual).max := by
  rw [max_eq_sup_withBot, sup_image]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset αᵒᵈ
⊢ WithTop.map (⇑ofDual) (Finset.min s) = sup s (WithBot.some ∘ ⇑ofDual)

Next tactic:
exact congr_fun Option.map_id _
theorem map_ofDual_max (s : Finset αᵒᵈ) : s.max.map ofDual = (s.image ofDual).min := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset αᵒᵈ
⊢ WithBot.map (⇑ofDual) (Finset.max s) = Finset.min (image (⇑ofDual) s)

Next tactic:
rw [min_eq_inf_withTop, inf_image]
theorem map_ofDual_max (s : Finset αᵒᵈ) : s.max.map ofDual = (s.image ofDual).min := by
  rw [min_eq_inf_withTop, inf_image]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset αᵒᵈ
⊢ WithBot.map (⇑ofDual) (Finset.max s) = inf s (WithTop.some ∘ ⇑ofDual)

Next tactic:
exact congr_fun Option.map_id _
theorem map_toDual_min (s : Finset α) : s.min.map toDual = (s.image toDual).max := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset α
⊢ WithTop.map (⇑toDual) (Finset.min s) = Finset.max (image (⇑toDual) s)

Next tactic:
rw [max_eq_sup_withBot, sup_image]
theorem map_toDual_min (s : Finset α) : s.min.map toDual = (s.image toDual).max := by
  rw [max_eq_sup_withBot, sup_image]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset α
⊢ WithTop.map (⇑toDual) (Finset.min s) = sup s (WithBot.some ∘ ⇑toDual)

Next tactic:
exact congr_fun Option.map_id _
theorem map_toDual_max (s : Finset α) : s.max.map toDual = (s.image toDual).min := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset α
⊢ WithBot.map (⇑toDual) (Finset.max s) = Finset.min (image (⇑toDual) s)

Next tactic:
rw [min_eq_inf_withTop, inf_image]
theorem map_toDual_max (s : Finset α) : s.max.map toDual = (s.image toDual).min := by
  rw [min_eq_inf_withTop, inf_image]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset α
⊢ WithBot.map (⇑toDual) (Finset.max s) = inf s (WithTop.some ∘ ⇑toDual)

Next tactic:
exact congr_fun Option.map_id _
theorem ofDual_min' {s : Finset αᵒᵈ} (hs : s.Nonempty) :
    ofDual (min' s hs) = max' (s.image ofDual) (hs.image _) := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset αᵒᵈ
hs : Finset.Nonempty s
⊢ ofDual (min' s hs) = max' (image (⇑ofDual) s) (_ : Finset.Nonempty (image (⇑ofDual) s))

Next tactic:
rw [← WithBot.coe_eq_coe]
theorem ofDual_min' {s : Finset αᵒᵈ} (hs : s.Nonempty) :
    ofDual (min' s hs) = max' (s.image ofDual) (hs.image _) := by
  rw [← WithBot.coe_eq_coe]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset αᵒᵈ
hs : Finset.Nonempty s
⊢ ↑(ofDual (min' s hs)) = ↑(max' (image (⇑ofDual) s) (_ : Finset.Nonempty (image (⇑ofDual) s)))

Next tactic:
simp only [min'_eq_inf', id_eq, ofDual_inf', Function.comp_apply, coe_sup', max'_eq_sup',
    sup_image]
theorem ofDual_min' {s : Finset αᵒᵈ} (hs : s.Nonempty) :
    ofDual (min' s hs) = max' (s.image ofDual) (hs.image _) := by
  rw [← WithBot.coe_eq_coe]
  simp only [min'_eq_inf', id_eq, ofDual_inf', Function.comp_apply, coe_sup', max'_eq_sup',
    sup_image]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset αᵒᵈ
hs : Finset.Nonempty s
⊢ sup s (WithBot.some ∘ fun x => ofDual x) = sup s ((WithBot.some ∘ fun x => x) ∘ ⇑ofDual)

Next tactic:
rfl
theorem ofDual_max' {s : Finset αᵒᵈ} (hs : s.Nonempty) :
    ofDual (max' s hs) = min' (s.image ofDual) (hs.image _) := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset αᵒᵈ
hs : Finset.Nonempty s
⊢ ofDual (max' s hs) = min' (image (⇑ofDual) s) (_ : Finset.Nonempty (image (⇑ofDual) s))

Next tactic:
rw [← WithTop.coe_eq_coe]
theorem ofDual_max' {s : Finset αᵒᵈ} (hs : s.Nonempty) :
    ofDual (max' s hs) = min' (s.image ofDual) (hs.image _) := by
  rw [← WithTop.coe_eq_coe]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset αᵒᵈ
hs : Finset.Nonempty s
⊢ ↑(ofDual (max' s hs)) = ↑(min' (image (⇑ofDual) s) (_ : Finset.Nonempty (image (⇑ofDual) s)))

Next tactic:
simp only [max'_eq_sup', id_eq, ofDual_sup', Function.comp_apply, coe_inf', min'_eq_inf',
    inf_image]
theorem ofDual_max' {s : Finset αᵒᵈ} (hs : s.Nonempty) :
    ofDual (max' s hs) = min' (s.image ofDual) (hs.image _) := by
  rw [← WithTop.coe_eq_coe]
  simp only [max'_eq_sup', id_eq, ofDual_sup', Function.comp_apply, coe_inf', min'_eq_inf',
    inf_image]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset αᵒᵈ
hs : Finset.Nonempty s
⊢ inf s (WithTop.some ∘ fun x => ofDual x) = inf s ((WithTop.some ∘ fun x => x) ∘ ⇑ofDual)

Next tactic:
rfl
theorem toDual_min' {s : Finset α} (hs : s.Nonempty) :
    toDual (min' s hs) = max' (s.image toDual) (hs.image _) := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset α
hs : Finset.Nonempty s
⊢ toDual (min' s hs) = max' (image (⇑toDual) s) (_ : Finset.Nonempty (image (⇑toDual) s))

Next tactic:
rw [← WithBot.coe_eq_coe]
theorem toDual_min' {s : Finset α} (hs : s.Nonempty) :
    toDual (min' s hs) = max' (s.image toDual) (hs.image _) := by
  rw [← WithBot.coe_eq_coe]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset α
hs : Finset.Nonempty s
⊢ ↑(toDual (min' s hs)) = ↑(max' (image (⇑toDual) s) (_ : Finset.Nonempty (image (⇑toDual) s)))

Next tactic:
simp only [min'_eq_inf', id_eq, toDual_inf', Function.comp_apply, coe_sup', max'_eq_sup',
    sup_image]
theorem toDual_min' {s : Finset α} (hs : s.Nonempty) :
    toDual (min' s hs) = max' (s.image toDual) (hs.image _) := by
  rw [← WithBot.coe_eq_coe]
  simp only [min'_eq_inf', id_eq, toDual_inf', Function.comp_apply, coe_sup', max'_eq_sup',
    sup_image]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset α
hs : Finset.Nonempty s
⊢ sup s (WithBot.some ∘ fun x => toDual x) = sup s ((WithBot.some ∘ fun x => x) ∘ ⇑toDual)

Next tactic:
rfl
theorem toDual_max' {s : Finset α} (hs : s.Nonempty) :
    toDual (max' s hs) = min' (s.image toDual) (hs.image _) := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset α
hs : Finset.Nonempty s
⊢ toDual (max' s hs) = min' (image (⇑toDual) s) (_ : Finset.Nonempty (image (⇑toDual) s))

Next tactic:
rw [← WithTop.coe_eq_coe]
theorem toDual_max' {s : Finset α} (hs : s.Nonempty) :
    toDual (max' s hs) = min' (s.image toDual) (hs.image _) := by
  rw [← WithTop.coe_eq_coe]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset α
hs : Finset.Nonempty s
⊢ ↑(toDual (max' s hs)) = ↑(min' (image (⇑toDual) s) (_ : Finset.Nonempty (image (⇑toDual) s)))

Next tactic:
simp only [max'_eq_sup', id_eq, toDual_sup', Function.comp_apply, coe_inf', min'_eq_inf',
    inf_image]
theorem toDual_max' {s : Finset α} (hs : s.Nonempty) :
    toDual (max' s hs) = min' (s.image toDual) (hs.image _) := by
  rw [← WithTop.coe_eq_coe]
  simp only [max'_eq_sup', id_eq, toDual_sup', Function.comp_apply, coe_inf', min'_eq_inf',
    inf_image]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H : Finset.Nonempty s✝
x : α
s : Finset α
hs : Finset.Nonempty s
⊢ inf s (WithTop.some ∘ fun x => toDual x) = inf s ((WithTop.some ∘ fun x => x) ∘ ⇑toDual)

Next tactic:
rfl
theorem max'_insert (a : α) (s : Finset α) (H : s.Nonempty) :
    (insert a s).max' (s.insert_nonempty a) = max (s.max' H) a :=
  (isGreatest_max' _ _).unique <| by
    

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
ι : Type u_5
κ : Type u_6
inst✝ : LinearOrder α
s✝ : Finset α
H✝ : Finset.Nonempty s✝
x a : α
s : Finset α
H : Finset.Nonempty s
⊢ IsGreatest (↑(insert a s)) (max (max' s H) a)

Next tactic:
rw [coe_insert, max_comm]