l3lab/ntp-mathlib huggingface dataset:
lemma CompleteLattice.independent_iff_supIndep_of_injOn {ι : Type*} {f : ι → α}
    (hf : InjOn f {i | f i ≠ ⊥}) :
    CompleteLattice.Independent f ↔ ∀ (s : Finset ι), s.SupIndep f := by
  refine ⟨fun h ↦ h.supIndep', fun h ↦ CompleteLattice.independent_def'.mpr fun i ↦ ?_⟩
  simp_rw [disjoint_iff, inf_sSup_eq_iSup_inf_sup_finset, iSup_eq_bot, ← disjoint_iff]
  intro s hs
  classical
  rw [← Finset.sup_erase_bot]
  set t := s.erase ⊥
  replace hf : InjOn f (f ⁻¹' t) := fun i hi j _ hij ↦ by refine hf ?_ ?_ hij <;> aesop
  have : (Finset.erase (insert i (t.preimage _ hf)) i).image f = t := by
    ext a
    simp only [Finset.mem_preimage, Finset.mem_erase, ne_eq, Finset.mem_insert, true_or, not_true,
      Finset.erase_insert_eq_erase, not_and, Finset.mem_image]
    refine ⟨by aesop, fun ⟨ha, has⟩ ↦ ?_⟩
    obtain ⟨j, hj, rfl⟩ := hs has
    

Proof state:
case a.intro.intro
ι✝ : Sort u_1
α : Type u_2
inst✝² : CompleteLattice α
f✝ : ι✝ → α
inst✝¹ : CompleteLattice α
inst✝ : IsCompactlyGenerated α
a b : α
s✝ : Set α
ι : Type u_3
f : ι → α
h : ∀ (s : Finset ι), Finset.SupIndep s f
i : ι
s : Finset α
hs : ↑s ⊆ f '' {j | j ≠ i}
t : Finset α := Finset.erase s ⊥
hf : InjOn f (f ⁻¹' ↑t)
j : ι
hj : j ∈ {j | j ≠ i}
x✝ : ¬f j = ⊥ ∧ f j ∈ s
ha : ¬f j = ⊥
has : f j ∈ s
⊢ ∃ a, (¬a = i ∧ ¬f a = ⊥ ∧ f a ∈ s) ∧ f a = f j

Next tactic:
exact ⟨j, ⟨hj, ha, has⟩, rfl⟩
lemma CompleteLattice.independent_iff_supIndep_of_injOn {ι : Type*} {f : ι → α}
    (hf : InjOn f {i | f i ≠ ⊥}) :
    CompleteLattice.Independent f ↔ ∀ (s : Finset ι), s.SupIndep f := by
  refine ⟨fun h ↦ h.supIndep', fun h ↦ CompleteLattice.independent_def'.mpr fun i ↦ ?_⟩
  simp_rw [disjoint_iff, inf_sSup_eq_iSup_inf_sup_finset, iSup_eq_bot, ← disjoint_iff]
  intro s hs
  classical
  rw [← Finset.sup_erase_bot]
  set t := s.erase ⊥
  replace hf : InjOn f (f ⁻¹' t) := fun i hi j _ hij ↦ by refine hf ?_ ?_ hij <;> aesop
  have : (Finset.erase (insert i (t.preimage _ hf)) i).image f = t := by
    ext a
    simp only [Finset.mem_preimage, Finset.mem_erase, ne_eq, Finset.mem_insert, true_or, not_true,
      Finset.erase_insert_eq_erase, not_and, Finset.mem_image]
    refine ⟨by aesop, fun ⟨ha, has⟩ ↦ ?_⟩
    obtain ⟨j, hj, rfl⟩ := hs has
    exact ⟨j, ⟨hj, ha, has⟩, rfl⟩
  

Proof state:
ι✝ : Sort u_1
α : Type u_2
inst✝² : CompleteLattice α
f✝ : ι✝ → α
inst✝¹ : CompleteLattice α
inst✝ : IsCompactlyGenerated α
a b : α
s✝ : Set α
ι : Type u_3
f : ι → α
h : ∀ (s : Finset ι), Finset.SupIndep s f
i : ι
s : Finset α
hs : ↑s ⊆ f '' {j | j ≠ i}
t : Finset α := Finset.erase s ⊥
hf : InjOn f (f ⁻¹' ↑t)
this : Finset.image f (Finset.erase (insert i (Finset.preimage t f hf)) i) = t
⊢ Disjoint (f i) (Finset.sup t id)

Next tactic:
rw [← this, Finset.sup_image]
lemma CompleteLattice.independent_iff_supIndep_of_injOn {ι : Type*} {f : ι → α}
    (hf : InjOn f {i | f i ≠ ⊥}) :
    CompleteLattice.Independent f ↔ ∀ (s : Finset ι), s.SupIndep f := by
  refine ⟨fun h ↦ h.supIndep', fun h ↦ CompleteLattice.independent_def'.mpr fun i ↦ ?_⟩
  simp_rw [disjoint_iff, inf_sSup_eq_iSup_inf_sup_finset, iSup_eq_bot, ← disjoint_iff]
  intro s hs
  classical
  rw [← Finset.sup_erase_bot]
  set t := s.erase ⊥
  replace hf : InjOn f (f ⁻¹' t) := fun i hi j _ hij ↦ by refine hf ?_ ?_ hij <;> aesop
  have : (Finset.erase (insert i (t.preimage _ hf)) i).image f = t := by
    ext a
    simp only [Finset.mem_preimage, Finset.mem_erase, ne_eq, Finset.mem_insert, true_or, not_true,
      Finset.erase_insert_eq_erase, not_and, Finset.mem_image]
    refine ⟨by aesop, fun ⟨ha, has⟩ ↦ ?_⟩
    obtain ⟨j, hj, rfl⟩ := hs has
    exact ⟨j, ⟨hj, ha, has⟩, rfl⟩
  rw [← this, Finset.sup_image]
  

Proof state:
ι✝ : Sort u_1
α : Type u_2
inst✝² : CompleteLattice α
f✝ : ι✝ → α
inst✝¹ : CompleteLattice α
inst✝ : IsCompactlyGenerated α
a b : α
s✝ : Set α
ι : Type u_3
f : ι → α
h : ∀ (s : Finset ι), Finset.SupIndep s f
i : ι
s : Finset α
hs : ↑s ⊆ f '' {j | j ≠ i}
t : Finset α := Finset.erase s ⊥
hf : InjOn f (f ⁻¹' ↑t)
this : Finset.image f (Finset.erase (insert i (Finset.preimage t f hf)) i) = t
⊢ Disjoint (f i) (Finset.sup (Finset.erase (insert i (Finset.preimage t f hf)) i) (id ∘ f))

Next tactic:
specialize h (insert i (t.preimage _ hf))
lemma CompleteLattice.independent_iff_supIndep_of_injOn {ι : Type*} {f : ι → α}
    (hf : InjOn f {i | f i ≠ ⊥}) :
    CompleteLattice.Independent f ↔ ∀ (s : Finset ι), s.SupIndep f := by
  refine ⟨fun h ↦ h.supIndep', fun h ↦ CompleteLattice.independent_def'.mpr fun i ↦ ?_⟩
  simp_rw [disjoint_iff, inf_sSup_eq_iSup_inf_sup_finset, iSup_eq_bot, ← disjoint_iff]
  intro s hs
  classical
  rw [← Finset.sup_erase_bot]
  set t := s.erase ⊥
  replace hf : InjOn f (f ⁻¹' t) := fun i hi j _ hij ↦ by refine hf ?_ ?_ hij <;> aesop
  have : (Finset.erase (insert i (t.preimage _ hf)) i).image f = t := by
    ext a
    simp only [Finset.mem_preimage, Finset.mem_erase, ne_eq, Finset.mem_insert, true_or, not_true,
      Finset.erase_insert_eq_erase, not_and, Finset.mem_image]
    refine ⟨by aesop, fun ⟨ha, has⟩ ↦ ?_⟩
    obtain ⟨j, hj, rfl⟩ := hs has
    exact ⟨j, ⟨hj, ha, has⟩, rfl⟩
  rw [← this, Finset.sup_image]
  specialize h (insert i (t.preimage _ hf))
  

Proof state:
ι✝ : Sort u_1
α : Type u_2
inst✝² : CompleteLattice α
f✝ : ι✝ → α
inst✝¹ : CompleteLattice α
inst✝ : IsCompactlyGenerated α
a b : α
s✝ : Set α
ι : Type u_3
f : ι → α
i : ι
s : Finset α
hs : ↑s ⊆ f '' {j | j ≠ i}
t : Finset α := Finset.erase s ⊥
hf : InjOn f (f ⁻¹' ↑t)
this : Finset.image f (Finset.erase (insert i (Finset.preimage t f hf)) i) = t
h : Finset.SupIndep (insert i (Finset.preimage t f hf)) f
⊢ Disjoint (f i) (Finset.sup (Finset.erase (insert i (Finset.preimage t f hf)) i) (id ∘ f))

Next tactic:
rw [Finset.supIndep_iff_disjoint_erase] at h
lemma CompleteLattice.independent_iff_supIndep_of_injOn {ι : Type*} {f : ι → α}
    (hf : InjOn f {i | f i ≠ ⊥}) :
    CompleteLattice.Independent f ↔ ∀ (s : Finset ι), s.SupIndep f := by
  refine ⟨fun h ↦ h.supIndep', fun h ↦ CompleteLattice.independent_def'.mpr fun i ↦ ?_⟩
  simp_rw [disjoint_iff, inf_sSup_eq_iSup_inf_sup_finset, iSup_eq_bot, ← disjoint_iff]
  intro s hs
  classical
  rw [← Finset.sup_erase_bot]
  set t := s.erase ⊥
  replace hf : InjOn f (f ⁻¹' t) := fun i hi j _ hij ↦ by refine hf ?_ ?_ hij <;> aesop
  have : (Finset.erase (insert i (t.preimage _ hf)) i).image f = t := by
    ext a
    simp only [Finset.mem_preimage, Finset.mem_erase, ne_eq, Finset.mem_insert, true_or, not_true,
      Finset.erase_insert_eq_erase, not_and, Finset.mem_image]
    refine ⟨by aesop, fun ⟨ha, has⟩ ↦ ?_⟩
    obtain ⟨j, hj, rfl⟩ := hs has
    exact ⟨j, ⟨hj, ha, has⟩, rfl⟩
  rw [← this, Finset.sup_image]
  specialize h (insert i (t.preimage _ hf))
  rw [Finset.supIndep_iff_disjoint_erase] at h
  

Proof state:
ι✝ : Sort u_1
α : Type u_2
inst✝² : CompleteLattice α
f✝ : ι✝ → α
inst✝¹ : CompleteLattice α
inst✝ : IsCompactlyGenerated α
a b : α
s✝ : Set α
ι : Type u_3
f : ι → α
i : ι
s : Finset α
hs : ↑s ⊆ f '' {j | j ≠ i}
t : Finset α := Finset.erase s ⊥
hf : InjOn f (f ⁻¹' ↑t)
this : Finset.image f (Finset.erase (insert i (Finset.preimage t f hf)) i) = t
h :
  ∀ i_1 ∈ insert i (Finset.preimage t f hf),
    Disjoint (f i_1) (Finset.sup (Finset.erase (insert i (Finset.preimage t f hf)) i_1) f)
⊢ Disjoint (f i) (Finset.sup (Finset.erase (insert i (Finset.preimage t f hf)) i) (id ∘ f))

Next tactic:
exact h i (Finset.mem_insert_self i _)
theorem CompleteLattice.setIndependent_iUnion_of_directed {η : Type*} {s : η → Set α}
    (hs : Directed (· ⊆ ·) s) (h : ∀ i, CompleteLattice.SetIndependent (s i)) :
    CompleteLattice.SetIndependent (⋃ i, s i) := by
  

Proof state:
ι : Sort u_1
α : Type u_2
inst✝² : CompleteLattice α
f : ι → α
inst✝¹ : CompleteLattice α
inst✝ : IsCompactlyGenerated α
a b : α
s✝ : Set α
η : Type u_3
s : η → Set α
hs : Directed (fun x x_1 => x ⊆ x_1) s
h : ∀ (i : η), SetIndependent (s i)
⊢ SetIndependent (⋃ i, s i)

Next tactic:
by_cases hη : Nonempty η
theorem CompleteLattice.setIndependent_iUnion_of_directed {η : Type*} {s : η → Set α}
    (hs : Directed (· ⊆ ·) s) (h : ∀ i, CompleteLattice.SetIndependent (s i)) :
    CompleteLattice.SetIndependent (⋃ i, s i) := by
  by_cases hη : Nonempty η
  · 

Proof state:
case pos
ι : Sort u_1
α : Type u_2
inst✝² : CompleteLattice α
f : ι → α
inst✝¹ : CompleteLattice α
inst✝ : IsCompactlyGenerated α
a b : α
s✝ : Set α
η : Type u_3
s : η → Set α
hs : Directed (fun x x_1 => x ⊆ x_1) s
h : ∀ (i : η), SetIndependent (s i)
hη : Nonempty η
⊢ SetIndependent (⋃ i, s i)

Next tactic:
rw [CompleteLattice.setIndependent_iff_finite]
theorem CompleteLattice.setIndependent_iUnion_of_directed {η : Type*} {s : η → Set α}
    (hs : Directed (· ⊆ ·) s) (h : ∀ i, CompleteLattice.SetIndependent (s i)) :
    CompleteLattice.SetIndependent (⋃ i, s i) := by
  by_cases hη : Nonempty η
  · rw [CompleteLattice.setIndependent_iff_finite]
    

Proof state:
case pos
ι : Sort u_1
α : Type u_2
inst✝² : CompleteLattice α
f : ι → α
inst✝¹ : CompleteLattice α
inst✝ : IsCompactlyGenerated α
a b : α
s✝ : Set α
η : Type u_3
s : η → Set α
hs : Directed (fun x x_1 => x ⊆ x_1) s
h : ∀ (i : η), SetIndependent (s i)
hη : Nonempty η
⊢ ∀ (t : Finset α), ↑t ⊆ ⋃ i, s i → SetIndependent ↑t

Next tactic:
intro t ht
theorem CompleteLattice.setIndependent_iUnion_of_directed {η : Type*} {s : η → Set α}
    (hs : Directed (· ⊆ ·) s) (h : ∀ i, CompleteLattice.SetIndependent (s i)) :
    CompleteLattice.SetIndependent (⋃ i, s i) := by
  by_cases hη : Nonempty η
  · rw [CompleteLattice.setIndependent_iff_finite]
    intro t ht
    

Proof state:
case pos
ι : Sort u_1
α : Type u_2
inst✝² : CompleteLattice α
f : ι → α
inst✝¹ : CompleteLattice α
inst✝ : IsCompactlyGenerated α
a b : α
s✝ : Set α
η : Type u_3
s : η → Set α
hs : Directed (fun x x_1 => x ⊆ x_1) s
h : ∀ (i : η), SetIndependent (s i)
hη : Nonempty η
t : Finset α
ht : ↑t ⊆ ⋃ i, s i
⊢ SetIndependent ↑t

Next tactic:
obtain ⟨I, fi, hI⟩ := Set.finite_subset_iUnion t.finite_toSet ht
theorem CompleteLattice.setIndependent_iUnion_of_directed {η : Type*} {s : η → Set α}
    (hs : Directed (· ⊆ ·) s) (h : ∀ i, CompleteLattice.SetIndependent (s i)) :
    CompleteLattice.SetIndependent (⋃ i, s i) := by
  by_cases hη : Nonempty η
  · rw [CompleteLattice.setIndependent_iff_finite]
    intro t ht
    obtain ⟨I, fi, hI⟩ := Set.finite_subset_iUnion t.finite_toSet ht
    

Proof state:
case pos.intro.intro
ι : Sort u_1
α : Type u_2
inst✝² : CompleteLattice α
f : ι → α
inst✝¹ : CompleteLattice α
inst✝ : IsCompactlyGenerated α
a b : α
s✝ : Set α
η : Type u_3
s : η → Set α
hs : Directed (fun x x_1 => x ⊆ x_1) s
h : ∀ (i : η), SetIndependent (s i)
hη : Nonempty η
t : Finset α
ht : ↑t ⊆ ⋃ i, s i
I : Set η
fi : Set.Finite I
hI : ↑t ⊆ ⋃ i ∈ I, s i
⊢ SetIndependent ↑t

Next tactic:
obtain ⟨i, hi⟩ := hs.finset_le fi.toFinset
theorem CompleteLattice.setIndependent_iUnion_of_directed {η : Type*} {s : η → Set α}
    (hs : Directed (· ⊆ ·) s) (h : ∀ i, CompleteLattice.SetIndependent (s i)) :
    CompleteLattice.SetIndependent (⋃ i, s i) := by
  by_cases hη : Nonempty η
  · rw [CompleteLattice.setIndependent_iff_finite]
    intro t ht
    obtain ⟨I, fi, hI⟩ := Set.finite_subset_iUnion t.finite_toSet ht
    obtain ⟨i, hi⟩ := hs.finset_le fi.toFinset
    

Proof state:
case pos.intro.intro.intro
ι : Sort u_1
α : Type u_2
inst✝² : CompleteLattice α
f : ι → α
inst✝¹ : CompleteLattice α
inst✝ : IsCompactlyGenerated α
a b : α
s✝ : Set α
η : Type u_3
s : η → Set α
hs : Directed (fun x x_1 => x ⊆ x_1) s
h : ∀ (i : η), SetIndependent (s i)
hη : Nonempty η
t : Finset α
ht : ↑t ⊆ ⋃ i, s i
I : Set η
fi : Set.Finite I
hI : ↑t ⊆ ⋃ i ∈ I, s i
i : η
hi : ∀ i_1 ∈ Finite.toFinset fi, s i_1 ⊆ s i
⊢ SetIndependent ↑t

Next tactic:
exact (h i).mono
        (Set.Subset.trans hI <| Set.iUnion₂_subset fun j hj => hi j (fi.mem_toFinset.2 hj))
theorem CompleteLattice.setIndependent_iUnion_of_directed {η : Type*} {s : η → Set α}
    (hs : Directed (· ⊆ ·) s) (h : ∀ i, CompleteLattice.SetIndependent (s i)) :
    CompleteLattice.SetIndependent (⋃ i, s i) := by
  by_cases hη : Nonempty η
  · rw [CompleteLattice.setIndependent_iff_finite]
    intro t ht
    obtain ⟨I, fi, hI⟩ := Set.finite_subset_iUnion t.finite_toSet ht
    obtain ⟨i, hi⟩ := hs.finset_le fi.toFinset
    exact (h i).mono
        (Set.Subset.trans hI <| Set.iUnion₂_subset fun j hj => hi j (fi.mem_toFinset.2 hj))
  · 

Proof state:
case neg
ι : Sort u_1
α : Type u_2
inst✝² : CompleteLattice α
f : ι → α
inst✝¹ : CompleteLattice α
inst✝ : IsCompactlyGenerated α
a b : α
s✝ : Set α
η : Type u_3
s : η → Set α
hs : Directed (fun x x_1 => x ⊆ x_1) s
h : ∀ (i : η), SetIndependent (s i)
hη : ¬Nonempty η
⊢ SetIndependent (⋃ i, s i)

Next tactic:
rintro a ⟨_, ⟨i, _⟩, _⟩
theorem CompleteLattice.setIndependent_iUnion_of_directed {η : Type*} {s : η → Set α}
    (hs : Directed (· ⊆ ·) s) (h : ∀ i, CompleteLattice.SetIndependent (s i)) :
    CompleteLattice.SetIndependent (⋃ i, s i) := by
  by_cases hη : Nonempty η
  · rw [CompleteLattice.setIndependent_iff_finite]
    intro t ht
    obtain ⟨I, fi, hI⟩ := Set.finite_subset_iUnion t.finite_toSet ht
    obtain ⟨i, hi⟩ := hs.finset_le fi.toFinset
    exact (h i).mono
        (Set.Subset.trans hI <| Set.iUnion₂_subset fun j hj => hi j (fi.mem_toFinset.2 hj))
  · rintro a ⟨_, ⟨i, _⟩, _⟩
    

Proof state:
case neg.intro.intro.intro
ι : Sort u_1
α : Type u_2
inst✝² : CompleteLattice α
f : ι → α
inst✝¹ : CompleteLattice α
inst✝ : IsCompactlyGenerated α
a✝ b : α
s✝ : Set α
η : Type u_3
s : η → Set α
hs : Directed (fun x x_1 => x ⊆ x_1) s
h : ∀ (i : η), SetIndependent (s i)
hη : ¬Nonempty η
a : α
w✝ : Set α
right✝ : a ∈ w✝
i : η
h✝ : (fun i => s i) i = w✝
⊢ Disjoint a (sSup ((⋃ i, s i) \ {a}))

Next tactic:
exfalso
theorem CompleteLattice.setIndependent_iUnion_of_directed {η : Type*} {s : η → Set α}
    (hs : Directed (· ⊆ ·) s) (h : ∀ i, CompleteLattice.SetIndependent (s i)) :
    CompleteLattice.SetIndependent (⋃ i, s i) := by
  by_cases hη : Nonempty η
  · rw [CompleteLattice.setIndependent_iff_finite]
    intro t ht
    obtain ⟨I, fi, hI⟩ := Set.finite_subset_iUnion t.finite_toSet ht
    obtain ⟨i, hi⟩ := hs.finset_le fi.toFinset
    exact (h i).mono
        (Set.Subset.trans hI <| Set.iUnion₂_subset fun j hj => hi j (fi.mem_toFinset.2 hj))
  · rintro a ⟨_, ⟨i, _⟩, _⟩
    exfalso
    

Proof state:
case neg.intro.intro.intro.h
ι : Sort u_1
α : Type u_2
inst✝² : CompleteLattice α
f : ι → α
inst✝¹ : CompleteLattice α
inst✝ : IsCompactlyGenerated α
a✝ b : α
s✝ : Set α
η : Type u_3
s : η → Set α
hs : Directed (fun x x_1 => x ⊆ x_1) s
h : ∀ (i : η), SetIndependent (s i)
hη : ¬Nonempty η
a : α
w✝ : Set α
right✝ : a ∈ w✝
i : η
h✝ : (fun i => s i) i = w✝
⊢ False

Next tactic:
exact hη ⟨i⟩
theorem CompleteLattice.independent_sUnion_of_directed {s : Set (Set α)} (hs : DirectedOn (· ⊆ ·) s)
    (h : ∀ a ∈ s, CompleteLattice.SetIndependent a) : CompleteLattice.SetIndependent (⋃₀ s) := by
  

Proof state:
ι : Sort u_1
α : Type u_2
inst✝² : CompleteLattice α
f : ι → α
inst✝¹ : CompleteLattice α
inst✝ : IsCompactlyGenerated α
a b : α
s✝ : Set α
s : Set (Set α)
hs : DirectedOn (fun x x_1 => x ⊆ x_1) s
h : ∀ a ∈ s, SetIndependent a
⊢ SetIndependent (⋃₀ s)

Next tactic:
rw [Set.sUnion_eq_iUnion]
theorem CompleteLattice.independent_sUnion_of_directed {s : Set (Set α)} (hs : DirectedOn (· ⊆ ·) s)
    (h : ∀ a ∈ s, CompleteLattice.SetIndependent a) : CompleteLattice.SetIndependent (⋃₀ s) := by
  rw [Set.sUnion_eq_iUnion]
  

Proof state:
ι : Sort u_1
α : Type u_2
inst✝² : CompleteLattice α
f : ι → α
inst✝¹ : CompleteLattice α
inst✝ : IsCompactlyGenerated α
a b : α
s✝ : Set α
s : Set (Set α)
hs : DirectedOn (fun x x_1 => x ⊆ x_1) s
h : ∀ a ∈ s, SetIndependent a
⊢ SetIndependent (⋃ i, ↑i)

Next tactic:
exact CompleteLattice.setIndependent_iUnion_of_directed hs.directed_val (by simpa using h)
theorem CompleteLattice.independent_sUnion_of_directed {s : Set (Set α)} (hs : DirectedOn (· ⊆ ·) s)
    (h : ∀ a ∈ s, CompleteLattice.SetIndependent a) : CompleteLattice.SetIndependent (⋃₀ s) := by
  rw [Set.sUnion_eq_iUnion]
  exact CompleteLattice.setIndependent_iUnion_of_directed hs.directed_val (by 

Proof state:
ι : Sort u_1
α : Type u_2
inst✝² : CompleteLattice α
f : ι → α
inst✝¹ : CompleteLattice α
inst✝ : IsCompactlyGenerated α
a b : α
s✝ : Set α
s : Set (Set α)
hs : DirectedOn (fun x x_1 => x ⊆ x_1) s
h : ∀ a ∈ s, SetIndependent a
⊢ ∀ (i : ↑s), SetIndependent ↑i

Next tactic:
simpa using h
theorem isCompactlyGenerated_of_wellFounded (h : WellFounded ((· > ·) : α → α → Prop)) :
    IsCompactlyGenerated α := by
  

Proof state:
ι : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f : ι → α
h : WellFounded fun x x_1 => x > x_1
⊢ IsCompactlyGenerated α

Next tactic:
rw [wellFounded_iff_isSupFiniteCompact, isSupFiniteCompact_iff_all_elements_compact] at h
theorem isCompactlyGenerated_of_wellFounded (h : WellFounded ((· > ·) : α → α → Prop)) :
    IsCompactlyGenerated α := by
  rw [wellFounded_iff_isSupFiniteCompact, isSupFiniteCompact_iff_all_elements_compact] at h
  -- x is the join of the set of compact elements {x}
  

Proof state:
ι : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f : ι → α
h : ∀ (k : α), IsCompactElement k
⊢ IsCompactlyGenerated α

Next tactic:
exact ⟨fun x => ⟨{x}, ⟨fun x _ => h x, sSup_singleton⟩⟩⟩
/-- A compact element `k` has the property that any `b < k` lies below a "maximal element below
`k`", which is to say `[⊥, k]` is coatomic. -/
theorem Iic_coatomic_of_compact_element {k : α} (h : IsCompactElement k) :
    IsCoatomic (Set.Iic k) := by
  

Proof state:
ι : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f : ι → α
k : α
h : IsCompactElement k
⊢ IsCoatomic ↑(Iic k)

Next tactic:
constructor
/-- A compact element `k` has the property that any `b < k` lies below a "maximal element below
`k`", which is to say `[⊥, k]` is coatomic. -/
theorem Iic_coatomic_of_compact_element {k : α} (h : IsCompactElement k) :
    IsCoatomic (Set.Iic k) := by
  constructor
  

Proof state:
case eq_top_or_exists_le_coatom
ι : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f : ι → α
k : α
h : IsCompactElement k
⊢ ∀ (b : ↑(Iic k)), b = ⊤ ∨ ∃ a, IsCoatom a ∧ b ≤ a

Next tactic:
rintro ⟨b, hbk⟩
/-- A compact element `k` has the property that any `b < k` lies below a "maximal element below
`k`", which is to say `[⊥, k]` is coatomic. -/
theorem Iic_coatomic_of_compact_element {k : α} (h : IsCompactElement k) :
    IsCoatomic (Set.Iic k) := by
  constructor
  rintro ⟨b, hbk⟩
  

Proof state:
case eq_top_or_exists_le_coatom.mk
ι : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f : ι → α
k : α
h : IsCompactElement k
b : α
hbk : b ∈ Iic k
⊢ { val := b, property := hbk } = ⊤ ∨ ∃ a, IsCoatom a ∧ { val := b, property := hbk } ≤ a

Next tactic:
obtain rfl | H := eq_or_ne b k
/-- A compact element `k` has the property that any `b < k` lies below a "maximal element below
`k`", which is to say `[⊥, k]` is coatomic. -/
theorem Iic_coatomic_of_compact_element {k : α} (h : IsCompactElement k) :
    IsCoatomic (Set.Iic k) := by
  constructor
  rintro ⟨b, hbk⟩
  obtain rfl | H := eq_or_ne b k
  · 

Proof state:
case eq_top_or_exists_le_coatom.mk.inl
ι : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f : ι → α
b : α
h : IsCompactElement b
hbk : b ∈ Iic b
⊢ { val := b, property := hbk } = ⊤ ∨ ∃ a, IsCoatom a ∧ { val := b, property := hbk } ≤ a

Next tactic:
left
/-- A compact element `k` has the property that any `b < k` lies below a "maximal element below
`k`", which is to say `[⊥, k]` is coatomic. -/
theorem Iic_coatomic_of_compact_element {k : α} (h : IsCompactElement k) :
    IsCoatomic (Set.Iic k) := by
  constructor
  rintro ⟨b, hbk⟩
  obtain rfl | H := eq_or_ne b k
  · left; 

Proof state:
case eq_top_or_exists_le_coatom.mk.inl.h
ι : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f : ι → α
b : α
h : IsCompactElement b
hbk : b ∈ Iic b
⊢ { val := b, property := hbk } = ⊤

Next tactic:
ext
/-- A compact element `k` has the property that any `b < k` lies below a "maximal element below
`k`", which is to say `[⊥, k]` is coatomic. -/
theorem Iic_coatomic_of_compact_element {k : α} (h : IsCompactElement k) :
    IsCoatomic (Set.Iic k) := by
  constructor
  rintro ⟨b, hbk⟩
  obtain rfl | H := eq_or_ne b k
  · left; ext; 

Proof state:
case eq_top_or_exists_le_coatom.mk.inl.h.a
ι : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f : ι → α
b : α
h : IsCompactElement b
hbk : b ∈ Iic b
⊢ ↑{ val := b, property := hbk } = ↑⊤

Next tactic:
simp only [Set.Iic.coe_top, Subtype.coe_mk]
/-- A compact element `k` has the property that any `b < k` lies below a "maximal element below
`k`", which is to say `[⊥, k]` is coatomic. -/
theorem Iic_coatomic_of_compact_element {k : α} (h : IsCompactElement k) :
    IsCoatomic (Set.Iic k) := by
  constructor
  rintro ⟨b, hbk⟩
  obtain rfl | H := eq_or_ne b k
  · left; ext; simp only [Set.Iic.coe_top, Subtype.coe_mk]
  

Proof state:
case eq_top_or_exists_le_coatom.mk.inr
ι : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f : ι → α
k : α
h : IsCompactElement k
b : α
hbk : b ∈ Iic k
H : b ≠ k
⊢ { val := b, property := hbk } = ⊤ ∨ ∃ a, IsCoatom a ∧ { val := b, property := hbk } ≤ a

Next tactic:
right
/-- A compact element `k` has the property that any `b < k` lies below a "maximal element below
`k`", which is to say `[⊥, k]` is coatomic. -/
theorem Iic_coatomic_of_compact_element {k : α} (h : IsCompactElement k) :
    IsCoatomic (Set.Iic k) := by
  constructor
  rintro ⟨b, hbk⟩
  obtain rfl | H := eq_or_ne b k
  · left; ext; simp only [Set.Iic.coe_top, Subtype.coe_mk]
  right
  

Proof state:
case eq_top_or_exists_le_coatom.mk.inr.h
ι : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f : ι → α
k : α
h : IsCompactElement k
b : α
hbk : b ∈ Iic k
H : b ≠ k
⊢ ∃ a, IsCoatom a ∧ { val := b, property := hbk } ≤ a

Next tactic:
have ⟨a, a₀, ba, h⟩ := zorn_nonempty_partialOrder₀ (Set.Iio k) ?_ b (lt_of_le_of_ne hbk H)
/-- A compact element `k` has the property that any `b < k` lies below a "maximal element below
`k`", which is to say `[⊥, k]` is coatomic. -/
theorem Iic_coatomic_of_compact_element {k : α} (h : IsCompactElement k) :
    IsCoatomic (Set.Iic k) := by
  constructor
  rintro ⟨b, hbk⟩
  obtain rfl | H := eq_or_ne b k
  · left; ext; simp only [Set.Iic.coe_top, Subtype.coe_mk]
  right
  have ⟨a, a₀, ba, h⟩ := zorn_nonempty_partialOrder₀ (Set.Iio k) ?_ b (lt_of_le_of_ne hbk H)
  · 

Proof state:
case eq_top_or_exists_le_coatom.mk.inr.h.refine_2
ι : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f : ι → α
k : α
h✝ : IsCompactElement k
b : α
hbk : b ∈ Iic k
H : b ≠ k
a : α
a₀ : a ∈ Iio k
ba : b ≤ a
h : ∀ z ∈ Iio k, a ≤ z → z = a
⊢ ∃ a, IsCoatom a ∧ { val := b, property := hbk } ≤ a

Next tactic:
refine' ⟨⟨a, le_of_lt a₀⟩, ⟨ne_of_lt a₀, fun c hck => by_contradiction fun c₀ => _⟩, ba⟩
/-- A compact element `k` has the property that any `b < k` lies below a "maximal element below
`k`", which is to say `[⊥, k]` is coatomic. -/
theorem Iic_coatomic_of_compact_element {k : α} (h : IsCompactElement k) :
    IsCoatomic (Set.Iic k) := by
  constructor
  rintro ⟨b, hbk⟩
  obtain rfl | H := eq_or_ne b k
  · left; ext; simp only [Set.Iic.coe_top, Subtype.coe_mk]
  right
  have ⟨a, a₀, ba, h⟩ := zorn_nonempty_partialOrder₀ (Set.Iio k) ?_ b (lt_of_le_of_ne hbk H)
  · refine' ⟨⟨a, le_of_lt a₀⟩, ⟨ne_of_lt a₀, fun c hck => by_contradiction fun c₀ => _⟩, ba⟩
    

Proof state:
case eq_top_or_exists_le_coatom.mk.inr.h.refine_2
ι : Sort u_1
α : Type u_2
inst✝ : CompleteLattice α
f : ι → α
k : α
h✝ : IsCompactElement k
b : α
hbk : b ∈ Iic k
H : b ≠ k
a : α
a₀ : a ∈ Iio k
ba : b ≤ a
h : ∀ z ∈ Iio k, a ≤ z → z = a
c : ↑(Iic k)
hck : { val := a, property := (_ : a ≤ k) } < c
c₀ : ¬c = ⊤
⊢ False

Next tactic:
cases h c.1 (lt_of_le_of_ne c.2 fun con => c₀ (Subtype.ext con)) hck.le