l3lab/ntp-mathlib huggingface dataset:
/-- An element `k` is compact if and only if any directed set with `sSup` above
`k` already got above `k` at some point in the set. -/
theorem isCompactElement_iff_le_of_directed_sSup_le (k : α) :
    IsCompactElement k ↔
      ∀ s : Set α, s.Nonempty → DirectedOn (· ≤ ·) s → k ≤ sSup s → ∃ x : α, x ∈ s ∧ k ≤ x := by
  classical
    constructor
    · intro hk s hne hdir hsup
      obtain ⟨t, ht⟩ := hk s hsup
      -- certainly every element of t is below something in s, since ↑t ⊆ s.
      have t_below_s : ∀ x ∈ t, ∃ y ∈ s, x ≤ y := fun x hxt => ⟨x, ht.left hxt, le_rfl⟩
      obtain ⟨x, ⟨hxs, hsupx⟩⟩ := Finset.sup_le_of_le_directed s hne hdir t t_below_s
      exact ⟨x, ⟨hxs, le_trans ht.right hsupx⟩⟩
    · intro hk s hsup
      -- Consider the set of finite joins of elements of the (plain) set s.
      let S : Set α := { x | ∃ t : Finset α, ↑t ⊆ s ∧ x = t.sup id }
      -- S is directed, nonempty, and still has sup above k.
      have dir_US : DirectedOn (· ≤ ·) S := by
        rintro x ⟨c, hc⟩ y ⟨d, hd⟩
        use x ⊔ y
        constructor
        · use c ∪ d
          constructor
          · simp only [hc.left, hd.left, Set.union_subset_iff, Finset.coe_union, and_self_iff]
          · simp only [hc.right, hd.right, Finset.sup_union]
        simp only [and_self_iff, le_sup_left, le_sup_right]
      have sup_S : sSup s ≤ sSup S := by
        apply sSup_le_sSup
        intro x hx
        use {x}
        simpa only [and_true_iff, id.def, Finset.coe_singleton, eq_self_iff_true,
          Finset.sup_singleton, Set.singleton_subset_iff]
      have Sne : S.Nonempty := by
        suffices : ⊥ ∈ S
        exact Set.nonempty_of_mem this
        use ∅
        simp only [Set.empty_subset, Finset.coe_empty, Finset.sup_empty, eq_self_iff_true,
          and_self_iff]
      -- Now apply the defn of compact and finish.
      obtain ⟨j, ⟨hjS, hjk⟩⟩ := hk S Sne dir_US (le_trans hsup sup_S)
      obtain ⟨t, ⟨htS, htsup⟩⟩ := hjS
      use t
      exact ⟨htS, by 

Proof state:
ι : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f : ι → α
k : α
hk : ∀ (s : Set α), Set.Nonempty s → DirectedOn (fun x x_1 => x ≤ x_1) s → k ≤ sSup s → ∃ x ∈ s, k ≤ x
s : Set α
hsup : k ≤ sSup s
S : Set α := {x | ∃ t, ↑t ⊆ s ∧ x = Finset.sup t id}
dir_US : DirectedOn (fun x x_1 => x ≤ x_1) S
sup_S : sSup s ≤ sSup S
Sne : Set.Nonempty S
j : α
hjk : k ≤ j
t : Finset α
htS : ↑t ⊆ s
htsup : j = Finset.sup t id
⊢ k ≤ Finset.sup t id

Next tactic:
rwa [← htsup]
theorem IsCompactElement.exists_finset_of_le_iSup {k : α} (hk : IsCompactElement k) {ι : Type*}
    (f : ι → α) (h : k ≤ ⨆ i, f i) : ∃ s : Finset ι, k ≤ ⨆ i ∈ s, f i := by
  

Proof state:
ι✝ : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f✝ : ι✝ → α
k : α
hk : IsCompactElement k
ι : Type u_3
f : ι → α
h : k ≤ ⨆ i, f i
⊢ ∃ s, k ≤ ⨆ i ∈ s, f i

Next tactic:
classical
    let g : Finset ι → α := fun s => ⨆ i ∈ s, f i
    have h1 : DirectedOn (· ≤ ·) (Set.range g) := by
      rintro - ⟨s, rfl⟩ - ⟨t, rfl⟩
      exact
        ⟨g (s ∪ t), ⟨s ∪ t, rfl⟩, iSup_le_iSup_of_subset (Finset.subset_union_left s t),
          iSup_le_iSup_of_subset (Finset.subset_union_right s t)⟩
    have h2 : k ≤ sSup (Set.range g) :=
      h.trans
        (iSup_le fun i =>
          le_sSup_of_le ⟨{i}, rfl⟩
            (le_iSup_of_le i (le_iSup_of_le (Finset.mem_singleton_self i) le_rfl)))
    obtain ⟨-, ⟨s, rfl⟩, hs⟩ :=
      (isCompactElement_iff_le_of_directed_sSup_le α k).mp hk (Set.range g) (Set.range_nonempty g)
        h1 h2
    exact ⟨s, hs⟩
theorem IsCompactElement.exists_finset_of_le_iSup {k : α} (hk : IsCompactElement k) {ι : Type*}
    (f : ι → α) (h : k ≤ ⨆ i, f i) : ∃ s : Finset ι, k ≤ ⨆ i ∈ s, f i := by
  classical
    

Proof state:
ι✝ : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f✝ : ι✝ → α
k : α
hk : IsCompactElement k
ι : Type u_3
f : ι → α
h : k ≤ ⨆ i, f i
⊢ ∃ s, k ≤ ⨆ i ∈ s, f i

Next tactic:
let g : Finset ι → α := fun s => ⨆ i ∈ s, f i
theorem IsCompactElement.exists_finset_of_le_iSup {k : α} (hk : IsCompactElement k) {ι : Type*}
    (f : ι → α) (h : k ≤ ⨆ i, f i) : ∃ s : Finset ι, k ≤ ⨆ i ∈ s, f i := by
  classical
    let g : Finset ι → α := fun s => ⨆ i ∈ s, f i
    

Proof state:
ι✝ : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f✝ : ι✝ → α
k : α
hk : IsCompactElement k
ι : Type u_3
f : ι → α
h : k ≤ ⨆ i, f i
g : Finset ι → α := fun s => ⨆ i ∈ s, f i
⊢ ∃ s, k ≤ ⨆ i ∈ s, f i

Next tactic:
have h1 : DirectedOn (· ≤ ·) (Set.range g) := by
      rintro - ⟨s, rfl⟩ - ⟨t, rfl⟩
      exact
        ⟨g (s ∪ t), ⟨s ∪ t, rfl⟩, iSup_le_iSup_of_subset (Finset.subset_union_left s t),
          iSup_le_iSup_of_subset (Finset.subset_union_right s t)⟩
theorem IsCompactElement.exists_finset_of_le_iSup {k : α} (hk : IsCompactElement k) {ι : Type*}
    (f : ι → α) (h : k ≤ ⨆ i, f i) : ∃ s : Finset ι, k ≤ ⨆ i ∈ s, f i := by
  classical
    let g : Finset ι → α := fun s => ⨆ i ∈ s, f i
    have h1 : DirectedOn (· ≤ ·) (Set.range g) := by
      

Proof state:
ι✝ : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f✝ : ι✝ → α
k : α
hk : IsCompactElement k
ι : Type u_3
f : ι → α
h : k ≤ ⨆ i, f i
g : Finset ι → α := fun s => ⨆ i ∈ s, f i
⊢ DirectedOn (fun x x_1 => x ≤ x_1) (range g)

Next tactic:
rintro - ⟨s, rfl⟩ - ⟨t, rfl⟩
theorem IsCompactElement.exists_finset_of_le_iSup {k : α} (hk : IsCompactElement k) {ι : Type*}
    (f : ι → α) (h : k ≤ ⨆ i, f i) : ∃ s : Finset ι, k ≤ ⨆ i ∈ s, f i := by
  classical
    let g : Finset ι → α := fun s => ⨆ i ∈ s, f i
    have h1 : DirectedOn (· ≤ ·) (Set.range g) := by
      rintro - ⟨s, rfl⟩ - ⟨t, rfl⟩
      

Proof state:
case intro.intro
ι✝ : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f✝ : ι✝ → α
k : α
hk : IsCompactElement k
ι : Type u_3
f : ι → α
h : k ≤ ⨆ i, f i
g : Finset ι → α := fun s => ⨆ i ∈ s, f i
s t : Finset ι
⊢ ∃ z ∈ range g, (fun x x_1 => x ≤ x_1) (g s) z ∧ (fun x x_1 => x ≤ x_1) (g t) z

Next tactic:
exact
        ⟨g (s ∪ t), ⟨s ∪ t, rfl⟩, iSup_le_iSup_of_subset (Finset.subset_union_left s t),
          iSup_le_iSup_of_subset (Finset.subset_union_right s t)⟩
theorem IsCompactElement.exists_finset_of_le_iSup {k : α} (hk : IsCompactElement k) {ι : Type*}
    (f : ι → α) (h : k ≤ ⨆ i, f i) : ∃ s : Finset ι, k ≤ ⨆ i ∈ s, f i := by
  classical
    let g : Finset ι → α := fun s => ⨆ i ∈ s, f i
    have h1 : DirectedOn (· ≤ ·) (Set.range g) := by
      rintro - ⟨s, rfl⟩ - ⟨t, rfl⟩
      exact
        ⟨g (s ∪ t), ⟨s ∪ t, rfl⟩, iSup_le_iSup_of_subset (Finset.subset_union_left s t),
          iSup_le_iSup_of_subset (Finset.subset_union_right s t)⟩
    

Proof state:
ι✝ : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f✝ : ι✝ → α
k : α
hk : IsCompactElement k
ι : Type u_3
f : ι → α
h : k ≤ ⨆ i, f i
g : Finset ι → α := fun s => ⨆ i ∈ s, f i
h1 : DirectedOn (fun x x_1 => x ≤ x_1) (range g)
⊢ ∃ s, k ≤ ⨆ i ∈ s, f i

Next tactic:
have h2 : k ≤ sSup (Set.range g) :=
      h.trans
        (iSup_le fun i =>
          le_sSup_of_le ⟨{i}, rfl⟩
            (le_iSup_of_le i (le_iSup_of_le (Finset.mem_singleton_self i) le_rfl)))
theorem IsCompactElement.exists_finset_of_le_iSup {k : α} (hk : IsCompactElement k) {ι : Type*}
    (f : ι → α) (h : k ≤ ⨆ i, f i) : ∃ s : Finset ι, k ≤ ⨆ i ∈ s, f i := by
  classical
    let g : Finset ι → α := fun s => ⨆ i ∈ s, f i
    have h1 : DirectedOn (· ≤ ·) (Set.range g) := by
      rintro - ⟨s, rfl⟩ - ⟨t, rfl⟩
      exact
        ⟨g (s ∪ t), ⟨s ∪ t, rfl⟩, iSup_le_iSup_of_subset (Finset.subset_union_left s t),
          iSup_le_iSup_of_subset (Finset.subset_union_right s t)⟩
    have h2 : k ≤ sSup (Set.range g) :=
      h.trans
        (iSup_le fun i =>
          le_sSup_of_le ⟨{i}, rfl⟩
            (le_iSup_of_le i (le_iSup_of_le (Finset.mem_singleton_self i) le_rfl)))
    

Proof state:
ι✝ : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f✝ : ι✝ → α
k : α
hk : IsCompactElement k
ι : Type u_3
f : ι → α
h : k ≤ ⨆ i, f i
g : Finset ι → α := fun s => ⨆ i ∈ s, f i
h1 : DirectedOn (fun x x_1 => x ≤ x_1) (range g)
h2 : k ≤ sSup (range g)
⊢ ∃ s, k ≤ ⨆ i ∈ s, f i

Next tactic:
obtain ⟨-, ⟨s, rfl⟩, hs⟩ :=
      (isCompactElement_iff_le_of_directed_sSup_le α k).mp hk (Set.range g) (Set.range_nonempty g)
        h1 h2
theorem IsCompactElement.exists_finset_of_le_iSup {k : α} (hk : IsCompactElement k) {ι : Type*}
    (f : ι → α) (h : k ≤ ⨆ i, f i) : ∃ s : Finset ι, k ≤ ⨆ i ∈ s, f i := by
  classical
    let g : Finset ι → α := fun s => ⨆ i ∈ s, f i
    have h1 : DirectedOn (· ≤ ·) (Set.range g) := by
      rintro - ⟨s, rfl⟩ - ⟨t, rfl⟩
      exact
        ⟨g (s ∪ t), ⟨s ∪ t, rfl⟩, iSup_le_iSup_of_subset (Finset.subset_union_left s t),
          iSup_le_iSup_of_subset (Finset.subset_union_right s t)⟩
    have h2 : k ≤ sSup (Set.range g) :=
      h.trans
        (iSup_le fun i =>
          le_sSup_of_le ⟨{i}, rfl⟩
            (le_iSup_of_le i (le_iSup_of_le (Finset.mem_singleton_self i) le_rfl)))
    obtain ⟨-, ⟨s, rfl⟩, hs⟩ :=
      (isCompactElement_iff_le_of_directed_sSup_le α k).mp hk (Set.range g) (Set.range_nonempty g)
        h1 h2
    

Proof state:
case intro.intro.intro
ι✝ : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f✝ : ι✝ → α
k : α
hk : IsCompactElement k
ι : Type u_3
f : ι → α
h : k ≤ ⨆ i, f i
g : Finset ι → α := fun s => ⨆ i ∈ s, f i
h1 : DirectedOn (fun x x_1 => x ≤ x_1) (range g)
h2 : k ≤ sSup (range g)
s : Finset ι
hs : k ≤ g s
⊢ ∃ s, k ≤ ⨆ i ∈ s, f i

Next tactic:
exact ⟨s, hs⟩
/-- A compact element `k` has the property that any directed set lying strictly below `k` has
its `sSup` strictly below `k`. -/
theorem IsCompactElement.directed_sSup_lt_of_lt {α : Type*} [CompleteLattice α] {k : α}
    (hk : IsCompactElement k) {s : Set α} (hemp : s.Nonempty) (hdir : DirectedOn (· ≤ ·) s)
    (hbelow : ∀ x ∈ s, x < k) : sSup s < k := by
  

Proof state:
ι : Sort u_1
α✝ : Type u_2
inst✝¹ : CompleteLattice α✝
f : ι → α✝
α : Type u_3
inst✝ : CompleteLattice α
k : α
hk : IsCompactElement k
s : Set α
hemp : Set.Nonempty s
hdir : DirectedOn (fun x x_1 => x ≤ x_1) s
hbelow : ∀ x ∈ s, x < k
⊢ sSup s < k

Next tactic:
rw [isCompactElement_iff_le_of_directed_sSup_le] at hk
/-- A compact element `k` has the property that any directed set lying strictly below `k` has
its `sSup` strictly below `k`. -/
theorem IsCompactElement.directed_sSup_lt_of_lt {α : Type*} [CompleteLattice α] {k : α}
    (hk : IsCompactElement k) {s : Set α} (hemp : s.Nonempty) (hdir : DirectedOn (· ≤ ·) s)
    (hbelow : ∀ x ∈ s, x < k) : sSup s < k := by
  rw [isCompactElement_iff_le_of_directed_sSup_le] at hk
  

Proof state:
ι : Sort u_1
α✝ : Type u_2
inst✝¹ : CompleteLattice α✝
f : ι → α✝
α : Type u_3
inst✝ : CompleteLattice α
k : α
hk : ∀ (s : Set α), Set.Nonempty s → DirectedOn (fun x x_1 => x ≤ x_1) s → k ≤ sSup s → ∃ x ∈ s, k ≤ x
s : Set α
hemp : Set.Nonempty s
hdir : DirectedOn (fun x x_1 => x ≤ x_1) s
hbelow : ∀ x ∈ s, x < k
⊢ sSup s < k

Next tactic:
by_contra h
/-- A compact element `k` has the property that any directed set lying strictly below `k` has
its `sSup` strictly below `k`. -/
theorem IsCompactElement.directed_sSup_lt_of_lt {α : Type*} [CompleteLattice α] {k : α}
    (hk : IsCompactElement k) {s : Set α} (hemp : s.Nonempty) (hdir : DirectedOn (· ≤ ·) s)
    (hbelow : ∀ x ∈ s, x < k) : sSup s < k := by
  rw [isCompactElement_iff_le_of_directed_sSup_le] at hk
  by_contra h
  

Proof state:
ι : Sort u_1
α✝ : Type u_2
inst✝¹ : CompleteLattice α✝
f : ι → α✝
α : Type u_3
inst✝ : CompleteLattice α
k : α
hk : ∀ (s : Set α), Set.Nonempty s → DirectedOn (fun x x_1 => x ≤ x_1) s → k ≤ sSup s → ∃ x ∈ s, k ≤ x
s : Set α
hemp : Set.Nonempty s
hdir : DirectedOn (fun x x_1 => x ≤ x_1) s
hbelow : ∀ x ∈ s, x < k
h : ¬sSup s < k
⊢ False

Next tactic:
have sSup' : sSup s ≤ k := sSup_le s k fun s hs => (hbelow s hs).le
/-- A compact element `k` has the property that any directed set lying strictly below `k` has
its `sSup` strictly below `k`. -/
theorem IsCompactElement.directed_sSup_lt_of_lt {α : Type*} [CompleteLattice α] {k : α}
    (hk : IsCompactElement k) {s : Set α} (hemp : s.Nonempty) (hdir : DirectedOn (· ≤ ·) s)
    (hbelow : ∀ x ∈ s, x < k) : sSup s < k := by
  rw [isCompactElement_iff_le_of_directed_sSup_le] at hk
  by_contra h
  have sSup' : sSup s ≤ k := sSup_le s k fun s hs => (hbelow s hs).le
  

Proof state:
ι : Sort u_1
α✝ : Type u_2
inst✝¹ : CompleteLattice α✝
f : ι → α✝
α : Type u_3
inst✝ : CompleteLattice α
k : α
hk : ∀ (s : Set α), Set.Nonempty s → DirectedOn (fun x x_1 => x ≤ x_1) s → k ≤ sSup s → ∃ x ∈ s, k ≤ x
s : Set α
hemp : Set.Nonempty s
hdir : DirectedOn (fun x x_1 => x ≤ x_1) s
hbelow : ∀ x ∈ s, x < k
h : ¬sSup s < k
sSup' : sSup s ≤ k
⊢ False

Next tactic:
replace sSup : sSup s = k := eq_iff_le_not_lt.mpr ⟨sSup', h⟩
/-- A compact element `k` has the property that any directed set lying strictly below `k` has
its `sSup` strictly below `k`. -/
theorem IsCompactElement.directed_sSup_lt_of_lt {α : Type*} [CompleteLattice α] {k : α}
    (hk : IsCompactElement k) {s : Set α} (hemp : s.Nonempty) (hdir : DirectedOn (· ≤ ·) s)
    (hbelow : ∀ x ∈ s, x < k) : sSup s < k := by
  rw [isCompactElement_iff_le_of_directed_sSup_le] at hk
  by_contra h
  have sSup' : sSup s ≤ k := sSup_le s k fun s hs => (hbelow s hs).le
  replace sSup : sSup s = k := eq_iff_le_not_lt.mpr ⟨sSup', h⟩
  

Proof state:
ι : Sort u_1
α✝ : Type u_2
inst✝¹ : CompleteLattice α✝
f : ι → α✝
α : Type u_3
inst✝ : CompleteLattice α
k : α
hk : ∀ (s : Set α), Set.Nonempty s → DirectedOn (fun x x_1 => x ≤ x_1) s → k ≤ SupSet.sSup s → ∃ x ∈ s, k ≤ x
s : Set α
hemp : Set.Nonempty s
hdir : DirectedOn (fun x x_1 => x ≤ x_1) s
hbelow : ∀ x ∈ s, x < k
h : ¬SupSet.sSup s < k
sSup' : SupSet.sSup s ≤ k
sSup : SupSet.sSup s = k
⊢ False

Next tactic:
obtain ⟨x, hxs, hkx⟩ := hk s hemp hdir sSup.symm.le
/-- A compact element `k` has the property that any directed set lying strictly below `k` has
its `sSup` strictly below `k`. -/
theorem IsCompactElement.directed_sSup_lt_of_lt {α : Type*} [CompleteLattice α] {k : α}
    (hk : IsCompactElement k) {s : Set α} (hemp : s.Nonempty) (hdir : DirectedOn (· ≤ ·) s)
    (hbelow : ∀ x ∈ s, x < k) : sSup s < k := by
  rw [isCompactElement_iff_le_of_directed_sSup_le] at hk
  by_contra h
  have sSup' : sSup s ≤ k := sSup_le s k fun s hs => (hbelow s hs).le
  replace sSup : sSup s = k := eq_iff_le_not_lt.mpr ⟨sSup', h⟩
  obtain ⟨x, hxs, hkx⟩ := hk s hemp hdir sSup.symm.le
  

Proof state:
case intro.intro
ι : Sort u_1
α✝ : Type u_2
inst✝¹ : CompleteLattice α✝
f : ι → α✝
α : Type u_3
inst✝ : CompleteLattice α
k : α
hk : ∀ (s : Set α), Set.Nonempty s → DirectedOn (fun x x_1 => x ≤ x_1) s → k ≤ SupSet.sSup s → ∃ x ∈ s, k ≤ x
s : Set α
hemp : Set.Nonempty s
hdir : DirectedOn (fun x x_1 => x ≤ x_1) s
hbelow : ∀ x ∈ s, x < k
h : ¬SupSet.sSup s < k
sSup' : SupSet.sSup s ≤ k
sSup : SupSet.sSup s = k
x : α
hxs : x ∈ s
hkx : k ≤ x
⊢ False

Next tactic:
obtain hxk := hbelow x hxs
/-- A compact element `k` has the property that any directed set lying strictly below `k` has
its `sSup` strictly below `k`. -/
theorem IsCompactElement.directed_sSup_lt_of_lt {α : Type*} [CompleteLattice α] {k : α}
    (hk : IsCompactElement k) {s : Set α} (hemp : s.Nonempty) (hdir : DirectedOn (· ≤ ·) s)
    (hbelow : ∀ x ∈ s, x < k) : sSup s < k := by
  rw [isCompactElement_iff_le_of_directed_sSup_le] at hk
  by_contra h
  have sSup' : sSup s ≤ k := sSup_le s k fun s hs => (hbelow s hs).le
  replace sSup : sSup s = k := eq_iff_le_not_lt.mpr ⟨sSup', h⟩
  obtain ⟨x, hxs, hkx⟩ := hk s hemp hdir sSup.symm.le
  obtain hxk := hbelow x hxs
  

Proof state:
case intro.intro
ι : Sort u_1
α✝ : Type u_2
inst✝¹ : CompleteLattice α✝
f : ι → α✝
α : Type u_3
inst✝ : CompleteLattice α
k : α
hk : ∀ (s : Set α), Set.Nonempty s → DirectedOn (fun x x_1 => x ≤ x_1) s → k ≤ SupSet.sSup s → ∃ x ∈ s, k ≤ x
s : Set α
hemp : Set.Nonempty s
hdir : DirectedOn (fun x x_1 => x ≤ x_1) s
hbelow : ∀ x ∈ s, x < k
h : ¬SupSet.sSup s < k
sSup' : SupSet.sSup s ≤ k
sSup : SupSet.sSup s = k
x : α
hxs : x ∈ s
hkx : k ≤ x
hxk : x < k
⊢ False

Next tactic:
exact hxk.ne (hxk.le.antisymm hkx)
theorem finset_sup_compact_of_compact {α β : Type*} [CompleteLattice α] {f : β → α} (s : Finset β)
    (h : ∀ x ∈ s, IsCompactElement (f x)) : IsCompactElement (s.sup f) := by
  

Proof state:
ι : Sort u_1
α✝ : Type u_2
inst✝¹ : CompleteLattice α✝
f✝ : ι → α✝
α : Type u_3
β : Type u_4
inst✝ : CompleteLattice α
f : β → α
s : Finset β
h : ∀ x ∈ s, IsCompactElement (f x)
⊢ IsCompactElement (Finset.sup s f)

Next tactic:
classical
    rw [isCompactElement_iff_le_of_directed_sSup_le]
    intro d hemp hdir hsup
    rw [← Function.comp.left_id f]
    rw [← Finset.sup_image]
    apply Finset.sup_le_of_le_directed d hemp hdir
    rintro x hx
    obtain ⟨p, ⟨hps, rfl⟩⟩ := Finset.mem_image.mp hx
    specialize h p hps
    rw [isCompactElement_iff_le_of_directed_sSup_le] at h
    specialize h d hemp hdir (le_trans (Finset.le_sup hps) hsup)
    simpa only [exists_prop]
theorem finset_sup_compact_of_compact {α β : Type*} [CompleteLattice α] {f : β → α} (s : Finset β)
    (h : ∀ x ∈ s, IsCompactElement (f x)) : IsCompactElement (s.sup f) := by
  classical
    

Proof state:
ι : Sort u_1
α✝ : Type u_2
inst✝¹ : CompleteLattice α✝
f✝ : ι → α✝
α : Type u_3
β : Type u_4
inst✝ : CompleteLattice α
f : β → α
s : Finset β
h : ∀ x ∈ s, IsCompactElement (f x)
⊢ IsCompactElement (Finset.sup s f)

Next tactic:
rw [isCompactElement_iff_le_of_directed_sSup_le]
theorem finset_sup_compact_of_compact {α β : Type*} [CompleteLattice α] {f : β → α} (s : Finset β)
    (h : ∀ x ∈ s, IsCompactElement (f x)) : IsCompactElement (s.sup f) := by
  classical
    rw [isCompactElement_iff_le_of_directed_sSup_le]
    

Proof state:
ι : Sort u_1
α✝ : Type u_2
inst✝¹ : CompleteLattice α✝
f✝ : ι → α✝
α : Type u_3
β : Type u_4
inst✝ : CompleteLattice α
f : β → α
s : Finset β
h : ∀ x ∈ s, IsCompactElement (f x)
⊢ ∀ (s_1 : Set α),
    Set.Nonempty s_1 → DirectedOn (fun x x_1 => x ≤ x_1) s_1 → Finset.sup s f ≤ sSup s_1 → ∃ x ∈ s_1, Finset.sup s f ≤ x

Next tactic:
intro d hemp hdir hsup
theorem finset_sup_compact_of_compact {α β : Type*} [CompleteLattice α] {f : β → α} (s : Finset β)
    (h : ∀ x ∈ s, IsCompactElement (f x)) : IsCompactElement (s.sup f) := by
  classical
    rw [isCompactElement_iff_le_of_directed_sSup_le]
    intro d hemp hdir hsup
    

Proof state:
ι : Sort u_1
α✝ : Type u_2
inst✝¹ : CompleteLattice α✝
f✝ : ι → α✝
α : Type u_3
β : Type u_4
inst✝ : CompleteLattice α
f : β → α
s : Finset β
h : ∀ x ∈ s, IsCompactElement (f x)
d : Set α
hemp : Set.Nonempty d
hdir : DirectedOn (fun x x_1 => x ≤ x_1) d
hsup : Finset.sup s f ≤ sSup d
⊢ ∃ x ∈ d, Finset.sup s f ≤ x

Next tactic:
rw [← Function.comp.left_id f]
theorem finset_sup_compact_of_compact {α β : Type*} [CompleteLattice α] {f : β → α} (s : Finset β)
    (h : ∀ x ∈ s, IsCompactElement (f x)) : IsCompactElement (s.sup f) := by
  classical
    rw [isCompactElement_iff_le_of_directed_sSup_le]
    intro d hemp hdir hsup
    rw [← Function.comp.left_id f]
    

Proof state:
ι : Sort u_1
α✝ : Type u_2
inst✝¹ : CompleteLattice α✝
f✝ : ι → α✝
α : Type u_3
β : Type u_4
inst✝ : CompleteLattice α
f : β → α
s : Finset β
h : ∀ x ∈ s, IsCompactElement (f x)
d : Set α
hemp : Set.Nonempty d
hdir : DirectedOn (fun x x_1 => x ≤ x_1) d
hsup : Finset.sup s f ≤ sSup d
⊢ ∃ x ∈ d, Finset.sup s (id ∘ f) ≤ x

Next tactic:
rw [← Finset.sup_image]
theorem finset_sup_compact_of_compact {α β : Type*} [CompleteLattice α] {f : β → α} (s : Finset β)
    (h : ∀ x ∈ s, IsCompactElement (f x)) : IsCompactElement (s.sup f) := by
  classical
    rw [isCompactElement_iff_le_of_directed_sSup_le]
    intro d hemp hdir hsup
    rw [← Function.comp.left_id f]
    rw [← Finset.sup_image]
    

Proof state:
ι : Sort u_1
α✝ : Type u_2
inst✝¹ : CompleteLattice α✝
f✝ : ι → α✝
α : Type u_3
β : Type u_4
inst✝ : CompleteLattice α
f : β → α
s : Finset β
h : ∀ x ∈ s, IsCompactElement (f x)
d : Set α
hemp : Set.Nonempty d
hdir : DirectedOn (fun x x_1 => x ≤ x_1) d
hsup : Finset.sup s f ≤ sSup d
⊢ ∃ x ∈ d, Finset.sup (Finset.image f s) id ≤ x

Next tactic:
apply Finset.sup_le_of_le_directed d hemp hdir
theorem finset_sup_compact_of_compact {α β : Type*} [CompleteLattice α] {f : β → α} (s : Finset β)
    (h : ∀ x ∈ s, IsCompactElement (f x)) : IsCompactElement (s.sup f) := by
  classical
    rw [isCompactElement_iff_le_of_directed_sSup_le]
    intro d hemp hdir hsup
    rw [← Function.comp.left_id f]
    rw [← Finset.sup_image]
    apply Finset.sup_le_of_le_directed d hemp hdir
    

Proof state:
case a
ι : Sort u_1
α✝ : Type u_2
inst✝¹ : CompleteLattice α✝
f✝ : ι → α✝
α : Type u_3
β : Type u_4
inst✝ : CompleteLattice α
f : β → α
s : Finset β
h : ∀ x ∈ s, IsCompactElement (f x)
d : Set α
hemp : Set.Nonempty d
hdir : DirectedOn (fun x x_1 => x ≤ x_1) d
hsup : Finset.sup s f ≤ sSup d
⊢ ∀ x ∈ Finset.image f s, ∃ y ∈ d, x ≤ y

Next tactic:
rintro x hx
theorem finset_sup_compact_of_compact {α β : Type*} [CompleteLattice α] {f : β → α} (s : Finset β)
    (h : ∀ x ∈ s, IsCompactElement (f x)) : IsCompactElement (s.sup f) := by
  classical
    rw [isCompactElement_iff_le_of_directed_sSup_le]
    intro d hemp hdir hsup
    rw [← Function.comp.left_id f]
    rw [← Finset.sup_image]
    apply Finset.sup_le_of_le_directed d hemp hdir
    rintro x hx
    

Proof state:
case a
ι : Sort u_1
α✝ : Type u_2
inst✝¹ : CompleteLattice α✝
f✝ : ι → α✝
α : Type u_3
β : Type u_4
inst✝ : CompleteLattice α
f : β → α
s : Finset β
h : ∀ x ∈ s, IsCompactElement (f x)
d : Set α
hemp : Set.Nonempty d
hdir : DirectedOn (fun x x_1 => x ≤ x_1) d
hsup : Finset.sup s f ≤ sSup d
x : α
hx : x ∈ Finset.image f s
⊢ ∃ y ∈ d, x ≤ y

Next tactic:
obtain ⟨p, ⟨hps, rfl⟩⟩ := Finset.mem_image.mp hx
theorem finset_sup_compact_of_compact {α β : Type*} [CompleteLattice α] {f : β → α} (s : Finset β)
    (h : ∀ x ∈ s, IsCompactElement (f x)) : IsCompactElement (s.sup f) := by
  classical
    rw [isCompactElement_iff_le_of_directed_sSup_le]
    intro d hemp hdir hsup
    rw [← Function.comp.left_id f]
    rw [← Finset.sup_image]
    apply Finset.sup_le_of_le_directed d hemp hdir
    rintro x hx
    obtain ⟨p, ⟨hps, rfl⟩⟩ := Finset.mem_image.mp hx
    

Proof state:
case a.intro.intro
ι : Sort u_1
α✝ : Type u_2
inst✝¹ : CompleteLattice α✝
f✝ : ι → α✝
α : Type u_3
β : Type u_4
inst✝ : CompleteLattice α
f : β → α
s : Finset β
h : ∀ x ∈ s, IsCompactElement (f x)
d : Set α
hemp : Set.Nonempty d
hdir : DirectedOn (fun x x_1 => x ≤ x_1) d
hsup : Finset.sup s f ≤ sSup d
p : β
hps : p ∈ s
hx : f p ∈ Finset.image f s
⊢ ∃ y ∈ d, f p ≤ y

Next tactic:
specialize h p hps
theorem finset_sup_compact_of_compact {α β : Type*} [CompleteLattice α] {f : β → α} (s : Finset β)
    (h : ∀ x ∈ s, IsCompactElement (f x)) : IsCompactElement (s.sup f) := by
  classical
    rw [isCompactElement_iff_le_of_directed_sSup_le]
    intro d hemp hdir hsup
    rw [← Function.comp.left_id f]
    rw [← Finset.sup_image]
    apply Finset.sup_le_of_le_directed d hemp hdir
    rintro x hx
    obtain ⟨p, ⟨hps, rfl⟩⟩ := Finset.mem_image.mp hx
    specialize h p hps
    

Proof state:
case a.intro.intro
ι : Sort u_1
α✝ : Type u_2
inst✝¹ : CompleteLattice α✝
f✝ : ι → α✝
α : Type u_3
β : Type u_4
inst✝ : CompleteLattice α
f : β → α
s : Finset β
d : Set α
hemp : Set.Nonempty d
hdir : DirectedOn (fun x x_1 => x ≤ x_1) d
hsup : Finset.sup s f ≤ sSup d
p : β
hps : p ∈ s
hx : f p ∈ Finset.image f s
h : IsCompactElement (f p)
⊢ ∃ y ∈ d, f p ≤ y

Next tactic:
rw [isCompactElement_iff_le_of_directed_sSup_le] at h
theorem finset_sup_compact_of_compact {α β : Type*} [CompleteLattice α] {f : β → α} (s : Finset β)
    (h : ∀ x ∈ s, IsCompactElement (f x)) : IsCompactElement (s.sup f) := by
  classical
    rw [isCompactElement_iff_le_of_directed_sSup_le]
    intro d hemp hdir hsup
    rw [← Function.comp.left_id f]
    rw [← Finset.sup_image]
    apply Finset.sup_le_of_le_directed d hemp hdir
    rintro x hx
    obtain ⟨p, ⟨hps, rfl⟩⟩ := Finset.mem_image.mp hx
    specialize h p hps
    rw [isCompactElement_iff_le_of_directed_sSup_le] at h
    

Proof state:
case a.intro.intro
ι : Sort u_1
α✝ : Type u_2
inst✝¹ : CompleteLattice α✝
f✝ : ι → α✝
α : Type u_3
β : Type u_4
inst✝ : CompleteLattice α
f : β → α
s : Finset β
d : Set α
hemp : Set.Nonempty d
hdir : DirectedOn (fun x x_1 => x ≤ x_1) d
hsup : Finset.sup s f ≤ sSup d
p : β
hps : p ∈ s
hx : f p ∈ Finset.image f s
h : ∀ (s : Set α), Set.Nonempty s → DirectedOn (fun x x_1 => x ≤ x_1) s → f p ≤ sSup s → ∃ x ∈ s, f p ≤ x
⊢ ∃ y ∈ d, f p ≤ y

Next tactic:
specialize h d hemp hdir (le_trans (Finset.le_sup hps) hsup)