l3lab/ntp-mathlib huggingface dataset:
theorem exists_seq_iSup_eq_top_iff_countable [CompleteLattice α] {p : α → Prop} (h : ∃ x, p x) :
    (∃ s : ℕ → α, (∀ n, p (s n)) ∧ ⨆ n, s n = ⊤) ↔
      ∃ S : Set α, S.Countable ∧ (∀ s ∈ S, p s) ∧ sSup S = ⊤ := by
  constructor
  · rintro ⟨s, hps, hs⟩
    refine' ⟨range s, countable_range s, forall_range_iff.2 hps, _⟩
    rwa [sSup_range]
  · rintro ⟨S, hSc, hps, hS⟩
    rcases eq_empty_or_nonempty S with (rfl | hne)
    · rw [sSup_empty] at hS
      haveI := subsingleton_of_bot_eq_top hS
      rcases h with ⟨x, hx⟩
      

Proof state:
case mpr.intro.intro.intro.inl.intro
α : Type u
β : Type v
γ : Type w
ι : Sort x
inst✝ : CompleteLattice α
p : α → Prop
hSc : Set.Countable ∅
hps : ∀ s ∈ ∅, p s
hS : ⊥ = ⊤
this : Subsingleton α
x : α
hx : p x
⊢ ∃ s, (∀ (n : ℕ), p (s n)) ∧ ⨆ n, s n = ⊤

Next tactic:
exact ⟨fun _ => x, fun _ => hx, Subsingleton.elim _ _⟩
theorem exists_seq_iSup_eq_top_iff_countable [CompleteLattice α] {p : α → Prop} (h : ∃ x, p x) :
    (∃ s : ℕ → α, (∀ n, p (s n)) ∧ ⨆ n, s n = ⊤) ↔
      ∃ S : Set α, S.Countable ∧ (∀ s ∈ S, p s) ∧ sSup S = ⊤ := by
  constructor
  · rintro ⟨s, hps, hs⟩
    refine' ⟨range s, countable_range s, forall_range_iff.2 hps, _⟩
    rwa [sSup_range]
  · rintro ⟨S, hSc, hps, hS⟩
    rcases eq_empty_or_nonempty S with (rfl | hne)
    · rw [sSup_empty] at hS
      haveI := subsingleton_of_bot_eq_top hS
      rcases h with ⟨x, hx⟩
      exact ⟨fun _ => x, fun _ => hx, Subsingleton.elim _ _⟩
    · 

Proof state:
case mpr.intro.intro.intro.inr
α : Type u
β : Type v
γ : Type w
ι : Sort x
inst✝ : CompleteLattice α
p : α → Prop
h : ∃ x, p x
S : Set α
hSc : Set.Countable S
hps : ∀ s ∈ S, p s
hS : sSup S = ⊤
hne : Set.Nonempty S
⊢ ∃ s, (∀ (n : ℕ), p (s n)) ∧ ⨆ n, s n = ⊤

Next tactic:
rcases (Set.countable_iff_exists_surjective hne).1 hSc with ⟨s, hs⟩
theorem exists_seq_iSup_eq_top_iff_countable [CompleteLattice α] {p : α → Prop} (h : ∃ x, p x) :
    (∃ s : ℕ → α, (∀ n, p (s n)) ∧ ⨆ n, s n = ⊤) ↔
      ∃ S : Set α, S.Countable ∧ (∀ s ∈ S, p s) ∧ sSup S = ⊤ := by
  constructor
  · rintro ⟨s, hps, hs⟩
    refine' ⟨range s, countable_range s, forall_range_iff.2 hps, _⟩
    rwa [sSup_range]
  · rintro ⟨S, hSc, hps, hS⟩
    rcases eq_empty_or_nonempty S with (rfl | hne)
    · rw [sSup_empty] at hS
      haveI := subsingleton_of_bot_eq_top hS
      rcases h with ⟨x, hx⟩
      exact ⟨fun _ => x, fun _ => hx, Subsingleton.elim _ _⟩
    · rcases (Set.countable_iff_exists_surjective hne).1 hSc with ⟨s, hs⟩
      

Proof state:
case mpr.intro.intro.intro.inr.intro
α : Type u
β : Type v
γ : Type w
ι : Sort x
inst✝ : CompleteLattice α
p : α → Prop
h : ∃ x, p x
S : Set α
hSc : Set.Countable S
hps : ∀ s ∈ S, p s
hS : sSup S = ⊤
hne : Set.Nonempty S
s : ℕ → ↑S
hs : Surjective s
⊢ ∃ s, (∀ (n : ℕ), p (s n)) ∧ ⨆ n, s n = ⊤

Next tactic:
refine' ⟨fun n => s n, fun n => hps _ (s n).coe_prop, _⟩
theorem exists_seq_iSup_eq_top_iff_countable [CompleteLattice α] {p : α → Prop} (h : ∃ x, p x) :
    (∃ s : ℕ → α, (∀ n, p (s n)) ∧ ⨆ n, s n = ⊤) ↔
      ∃ S : Set α, S.Countable ∧ (∀ s ∈ S, p s) ∧ sSup S = ⊤ := by
  constructor
  · rintro ⟨s, hps, hs⟩
    refine' ⟨range s, countable_range s, forall_range_iff.2 hps, _⟩
    rwa [sSup_range]
  · rintro ⟨S, hSc, hps, hS⟩
    rcases eq_empty_or_nonempty S with (rfl | hne)
    · rw [sSup_empty] at hS
      haveI := subsingleton_of_bot_eq_top hS
      rcases h with ⟨x, hx⟩
      exact ⟨fun _ => x, fun _ => hx, Subsingleton.elim _ _⟩
    · rcases (Set.countable_iff_exists_surjective hne).1 hSc with ⟨s, hs⟩
      refine' ⟨fun n => s n, fun n => hps _ (s n).coe_prop, _⟩
      

Proof state:
case mpr.intro.intro.intro.inr.intro
α : Type u
β : Type v
γ : Type w
ι : Sort x
inst✝ : CompleteLattice α
p : α → Prop
h : ∃ x, p x
S : Set α
hSc : Set.Countable S
hps : ∀ s ∈ S, p s
hS : sSup S = ⊤
hne : Set.Nonempty S
s : ℕ → ↑S
hs : Surjective s
⊢ ⨆ n, (fun n => ↑(s n)) n = ⊤

Next tactic:
rwa [hs.iSup_comp, ← sSup_eq_iSup']
theorem countable_iUnion {t : ι → Set α} [Countable ι] (ht : ∀ i, (t i).Countable) :
    (⋃ i, t i).Countable := by
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
t : ι → Set α
inst✝ : Countable ι
ht : ∀ (i : ι), Set.Countable (t i)
⊢ Set.Countable (⋃ i, t i)

Next tactic:
haveI := fun a => (ht a).to_subtype
theorem countable_iUnion {t : ι → Set α} [Countable ι] (ht : ∀ i, (t i).Countable) :
    (⋃ i, t i).Countable := by
  haveI := fun a => (ht a).to_subtype
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
t : ι → Set α
inst✝ : Countable ι
ht : ∀ (i : ι), Set.Countable (t i)
this : ∀ (a : ι), Countable ↑(t a)
⊢ Set.Countable (⋃ i, t i)

Next tactic:
rw [iUnion_eq_range_psigma]
theorem countable_iUnion {t : ι → Set α} [Countable ι] (ht : ∀ i, (t i).Countable) :
    (⋃ i, t i).Countable := by
  haveI := fun a => (ht a).to_subtype
  rw [iUnion_eq_range_psigma]
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
t : ι → Set α
inst✝ : Countable ι
ht : ∀ (i : ι), Set.Countable (t i)
this : ∀ (a : ι), Countable ↑(t a)
⊢ Set.Countable (range fun a => ↑a.snd)

Next tactic:
apply countable_range
theorem Countable.biUnion_iff {s : Set α} {t : ∀ a ∈ s, Set β} (hs : s.Countable) :
    (⋃ a ∈ s, t a ‹_›).Countable ↔ ∀ a (ha : a ∈ s), (t a ha).Countable := by
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
t : (a : α) → a ∈ s → Set β
hs : Set.Countable s
⊢ Set.Countable (⋃ a, ⋃ (h : a ∈ s), t a h) ↔ ∀ (a : α) (ha : a ∈ s), Set.Countable (t a ha)

Next tactic:
haveI := hs.to_subtype
theorem Countable.biUnion_iff {s : Set α} {t : ∀ a ∈ s, Set β} (hs : s.Countable) :
    (⋃ a ∈ s, t a ‹_›).Countable ↔ ∀ a (ha : a ∈ s), (t a ha).Countable := by
  haveI := hs.to_subtype
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
t : (a : α) → a ∈ s → Set β
hs : Set.Countable s
this : Countable ↑s
⊢ Set.Countable (⋃ a, ⋃ (h : a ∈ s), t a h) ↔ ∀ (a : α) (ha : a ∈ s), Set.Countable (t a ha)

Next tactic:
rw [biUnion_eq_iUnion, countable_iUnion_iff, SetCoe.forall']
theorem Countable.sUnion_iff {s : Set (Set α)} (hs : s.Countable) :
    (⋃₀ s).Countable ↔ ∀ a ∈ s, (a : _).Countable := by 

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set (Set α)
hs : Set.Countable s
⊢ Set.Countable (⋃₀ s) ↔ ∀ a ∈ s, Set.Countable a

Next tactic:
rw [sUnion_eq_biUnion, hs.biUnion_iff]
@[simp]
theorem countable_union {s t : Set α} : (s ∪ t).Countable ↔ s.Countable ∧ t.Countable := by
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
s t : Set α
⊢ Set.Countable (s ∪ t) ↔ Set.Countable s ∧ Set.Countable t

Next tactic:
simp [union_eq_iUnion, and_comm]
@[simp]
theorem countable_insert {s : Set α} {a : α} : (insert a s).Countable ↔ s.Countable := by
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
a : α
⊢ Set.Countable (insert a s) ↔ Set.Countable s

Next tactic:
simp only [insert_eq, countable_union, countable_singleton, true_and_iff]
/-- The set of finite subsets of a countable set is countable. -/
theorem countable_setOf_finite_subset {s : Set α} (hs : s.Countable) :
    { t | Set.Finite t ∧ t ⊆ s }.Countable := by
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
hs : Set.Countable s
⊢ Set.Countable {t | Set.Finite t ∧ t ⊆ s}

Next tactic:
haveI := hs.to_subtype
/-- The set of finite subsets of a countable set is countable. -/
theorem countable_setOf_finite_subset {s : Set α} (hs : s.Countable) :
    { t | Set.Finite t ∧ t ⊆ s }.Countable := by
  haveI := hs.to_subtype
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
hs : Set.Countable s
this : Countable ↑s
⊢ Set.Countable {t | Set.Finite t ∧ t ⊆ s}

Next tactic:
refine' Countable.mono _ (countable_range fun t : Finset s => Subtype.val '' (t : Set s))
/-- The set of finite subsets of a countable set is countable. -/
theorem countable_setOf_finite_subset {s : Set α} (hs : s.Countable) :
    { t | Set.Finite t ∧ t ⊆ s }.Countable := by
  haveI := hs.to_subtype
  refine' Countable.mono _ (countable_range fun t : Finset s => Subtype.val '' (t : Set s))
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
hs : Set.Countable s
this : Countable ↑s
⊢ {t | Set.Finite t ∧ t ⊆ s} ⊆ range fun t => Subtype.val '' ↑t

Next tactic:
rintro t ⟨ht, hts⟩
/-- The set of finite subsets of a countable set is countable. -/
theorem countable_setOf_finite_subset {s : Set α} (hs : s.Countable) :
    { t | Set.Finite t ∧ t ⊆ s }.Countable := by
  haveI := hs.to_subtype
  refine' Countable.mono _ (countable_range fun t : Finset s => Subtype.val '' (t : Set s))
  rintro t ⟨ht, hts⟩
  

Proof state:
case intro
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
hs : Set.Countable s
this : Countable ↑s
t : Set α
ht : Set.Finite t
hts : t ⊆ s
⊢ t ∈ range fun t => Subtype.val '' ↑t

Next tactic:
lift t to Set s using hts
/-- The set of finite subsets of a countable set is countable. -/
theorem countable_setOf_finite_subset {s : Set α} (hs : s.Countable) :
    { t | Set.Finite t ∧ t ⊆ s }.Countable := by
  haveI := hs.to_subtype
  refine' Countable.mono _ (countable_range fun t : Finset s => Subtype.val '' (t : Set s))
  rintro t ⟨ht, hts⟩
  lift t to Set s using hts
  

Proof state:
case intro.intro
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
hs : Set.Countable s
this : Countable ↑s
t : Set ↑s
ht : Set.Finite (Subtype.val '' t)
⊢ Subtype.val '' t ∈ range fun t => Subtype.val '' ↑t

Next tactic:
lift t to Finset s using ht.of_finite_image (Subtype.val_injective.injOn _)
/-- The set of finite subsets of a countable set is countable. -/
theorem countable_setOf_finite_subset {s : Set α} (hs : s.Countable) :
    { t | Set.Finite t ∧ t ⊆ s }.Countable := by
  haveI := hs.to_subtype
  refine' Countable.mono _ (countable_range fun t : Finset s => Subtype.val '' (t : Set s))
  rintro t ⟨ht, hts⟩
  lift t to Set s using hts
  lift t to Finset s using ht.of_finite_image (Subtype.val_injective.injOn _)
  

Proof state:
case intro.intro.intro
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
hs : Set.Countable s
this : Countable ↑s
t : Finset ↑s
ht : Set.Finite (Subtype.val '' ↑t)
⊢ Subtype.val '' ↑t ∈ range fun t => Subtype.val '' ↑t

Next tactic:
exact mem_range_self _
theorem countable_pi {π : α → Type*} [Finite α] {s : ∀ a, Set (π a)} (hs : ∀ a, (s a).Countable) :
    { f : ∀ a, π a | ∀ a, f a ∈ s a }.Countable := by
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
π : α → Type u_1
inst✝ : Finite α
s : (a : α) → Set (π a)
hs : ∀ (a : α), Set.Countable (s a)
⊢ Set.Countable {f | ∀ (a : α), f a ∈ s a}

Next tactic:
simpa only [← mem_univ_pi] using countable_univ_pi hs
protected theorem Countable.prod {s : Set α} {t : Set β} (hs : s.Countable) (ht : t.Countable) :
    Set.Countable (s ×ˢ t) := by
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
t : Set β
hs : Set.Countable s
ht : Set.Countable t
⊢ Set.Countable (s ×ˢ t)

Next tactic:
haveI : Countable s := hs.to_subtype
protected theorem Countable.prod {s : Set α} {t : Set β} (hs : s.Countable) (ht : t.Countable) :
    Set.Countable (s ×ˢ t) := by
  haveI : Countable s := hs.to_subtype
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
t : Set β
hs : Set.Countable s
ht : Set.Countable t
this : Countable ↑s
⊢ Set.Countable (s ×ˢ t)

Next tactic:
haveI : Countable t := ht.to_subtype
protected theorem Countable.prod {s : Set α} {t : Set β} (hs : s.Countable) (ht : t.Countable) :
    Set.Countable (s ×ˢ t) := by
  haveI : Countable s := hs.to_subtype
  haveI : Countable t := ht.to_subtype
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
t : Set β
hs : Set.Countable s
ht : Set.Countable t
this✝ : Countable ↑s
this : Countable ↑t
⊢ Set.Countable (s ×ˢ t)

Next tactic:
exact (Countable.of_equiv _ <| (Equiv.Set.prod _ _).symm).to_set
theorem Countable.image2 {s : Set α} {t : Set β} (hs : s.Countable) (ht : t.Countable)
    (f : α → β → γ) : (image2 f s t).Countable := by
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
t : Set β
hs : Set.Countable s
ht : Set.Countable t
f : α → β → γ
⊢ Set.Countable (Set.image2 f s t)

Next tactic:
rw [← image_prod]
theorem Countable.image2 {s : Set α} {t : Set β} (hs : s.Countable) (ht : t.Countable)
    (f : α → β → γ) : (image2 f s t).Countable := by
  rw [← image_prod]
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
t : Set β
hs : Set.Countable s
ht : Set.Countable t
f : α → β → γ
⊢ Set.Countable ((fun x => f x.1 x.2) '' s ×ˢ t)

Next tactic:
exact (hs.prod ht).image _
/-- If a family of disjoint sets is included in a countable set, then only countably many of
them are nonempty. -/
theorem countable_setOf_nonempty_of_disjoint {f : β → Set α}
    (hf : Pairwise (Disjoint on f)) {s : Set α} (h'f : ∀ t, f t ⊆ s) (hs : s.Countable) :
    Set.Countable {t | (f t).Nonempty} := by
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
f : β → Set α
hf : Pairwise (Disjoint on f)
s : Set α
h'f : ∀ (t : β), f t ⊆ s
hs : Set.Countable s
⊢ Set.Countable {t | Set.Nonempty (f t)}

Next tactic:
rw [← Set.countable_coe_iff] at hs ⊢
/-- If a family of disjoint sets is included in a countable set, then only countably many of
them are nonempty. -/
theorem countable_setOf_nonempty_of_disjoint {f : β → Set α}
    (hf : Pairwise (Disjoint on f)) {s : Set α} (h'f : ∀ t, f t ⊆ s) (hs : s.Countable) :
    Set.Countable {t | (f t).Nonempty} := by
  rw [← Set.countable_coe_iff] at hs ⊢
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
f : β → Set α
hf : Pairwise (Disjoint on f)
s : Set α
h'f : ∀ (t : β), f t ⊆ s
hs : Countable ↑s
⊢ Countable ↑{t | Set.Nonempty (f t)}

Next tactic:
have : ∀ t : {t // (f t).Nonempty}, ∃ x : s, x.1 ∈ f t := by
    rintro ⟨t, ⟨x, hx⟩⟩
    exact ⟨⟨x, (h'f t hx)⟩, hx⟩
/-- If a family of disjoint sets is included in a countable set, then only countably many of
them are nonempty. -/
theorem countable_setOf_nonempty_of_disjoint {f : β → Set α}
    (hf : Pairwise (Disjoint on f)) {s : Set α} (h'f : ∀ t, f t ⊆ s) (hs : s.Countable) :
    Set.Countable {t | (f t).Nonempty} := by
  rw [← Set.countable_coe_iff] at hs ⊢
  have : ∀ t : {t // (f t).Nonempty}, ∃ x : s, x.1 ∈ f t := by
    

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
f : β → Set α
hf : Pairwise (Disjoint on f)
s : Set α
h'f : ∀ (t : β), f t ⊆ s
hs : Countable ↑s
⊢ ∀ (t : { t // Set.Nonempty (f t) }), ∃ x, ↑x ∈ f ↑t

Next tactic:
rintro ⟨t, ⟨x, hx⟩⟩
/-- If a family of disjoint sets is included in a countable set, then only countably many of
them are nonempty. -/
theorem countable_setOf_nonempty_of_disjoint {f : β → Set α}
    (hf : Pairwise (Disjoint on f)) {s : Set α} (h'f : ∀ t, f t ⊆ s) (hs : s.Countable) :
    Set.Countable {t | (f t).Nonempty} := by
  rw [← Set.countable_coe_iff] at hs ⊢
  have : ∀ t : {t // (f t).Nonempty}, ∃ x : s, x.1 ∈ f t := by
    rintro ⟨t, ⟨x, hx⟩⟩
    

Proof state:
case mk.intro
α : Type u
β : Type v
γ : Type w
ι : Sort x
f : β → Set α
hf : Pairwise (Disjoint on f)
s : Set α
h'f : ∀ (t : β), f t ⊆ s
hs : Countable ↑s
t : β
x : α
hx : x ∈ f t
⊢ ∃ x_1, ↑x_1 ∈ f ↑{ val := t, property := (_ : ∃ x, x ∈ f t) }

Next tactic:
exact ⟨⟨x, (h'f t hx)⟩, hx⟩
/-- If a family of disjoint sets is included in a countable set, then only countably many of
them are nonempty. -/
theorem countable_setOf_nonempty_of_disjoint {f : β → Set α}
    (hf : Pairwise (Disjoint on f)) {s : Set α} (h'f : ∀ t, f t ⊆ s) (hs : s.Countable) :
    Set.Countable {t | (f t).Nonempty} := by
  rw [← Set.countable_coe_iff] at hs ⊢
  have : ∀ t : {t // (f t).Nonempty}, ∃ x : s, x.1 ∈ f t := by
    rintro ⟨t, ⟨x, hx⟩⟩
    exact ⟨⟨x, (h'f t hx)⟩, hx⟩
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
f : β → Set α
hf : Pairwise (Disjoint on f)
s : Set α
h'f : ∀ (t : β), f t ⊆ s
hs : Countable ↑s
this : ∀ (t : { t // Set.Nonempty (f t) }), ∃ x, ↑x ∈ f ↑t
⊢ Countable ↑{t | Set.Nonempty (f t)}

Next tactic:
choose F hF using this
/-- If a family of disjoint sets is included in a countable set, then only countably many of
them are nonempty. -/
theorem countable_setOf_nonempty_of_disjoint {f : β → Set α}
    (hf : Pairwise (Disjoint on f)) {s : Set α} (h'f : ∀ t, f t ⊆ s) (hs : s.Countable) :
    Set.Countable {t | (f t).Nonempty} := by
  rw [← Set.countable_coe_iff] at hs ⊢
  have : ∀ t : {t // (f t).Nonempty}, ∃ x : s, x.1 ∈ f t := by
    rintro ⟨t, ⟨x, hx⟩⟩
    exact ⟨⟨x, (h'f t hx)⟩, hx⟩
  choose F hF using this
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
f : β → Set α
hf : Pairwise (Disjoint on f)
s : Set α
h'f : ∀ (t : β), f t ⊆ s
hs : Countable ↑s
F : { t // Set.Nonempty (f t) } → ↑s
hF : ∀ (t : { t // Set.Nonempty (f t) }), ↑(F t) ∈ f ↑t
⊢ Countable ↑{t | Set.Nonempty (f t)}

Next tactic:
have A : Injective F := by
    rintro ⟨t, ht⟩ ⟨t', ht'⟩ htt'
    have A : (f t ∩ f t').Nonempty := by
      refine ⟨F ⟨t, ht⟩, hF _, ?_⟩
      rw [htt']
      exact hF _
    simp only [Subtype.mk.injEq]
    by_contra H
    exact not_disjoint_iff_nonempty_inter.2 A (hf H)
/-- If a family of disjoint sets is included in a countable set, then only countably many of
them are nonempty. -/
theorem countable_setOf_nonempty_of_disjoint {f : β → Set α}
    (hf : Pairwise (Disjoint on f)) {s : Set α} (h'f : ∀ t, f t ⊆ s) (hs : s.Countable) :
    Set.Countable {t | (f t).Nonempty} := by
  rw [← Set.countable_coe_iff] at hs ⊢
  have : ∀ t : {t // (f t).Nonempty}, ∃ x : s, x.1 ∈ f t := by
    rintro ⟨t, ⟨x, hx⟩⟩
    exact ⟨⟨x, (h'f t hx)⟩, hx⟩
  choose F hF using this
  have A : Injective F := by
    

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
f : β → Set α
hf : Pairwise (Disjoint on f)
s : Set α
h'f : ∀ (t : β), f t ⊆ s
hs : Countable ↑s
F : { t // Set.Nonempty (f t) } → ↑s
hF : ∀ (t : { t // Set.Nonempty (f t) }), ↑(F t) ∈ f ↑t
⊢ Injective F

Next tactic:
rintro ⟨t, ht⟩ ⟨t', ht'⟩ htt'
/-- If a family of disjoint sets is included in a countable set, then only countably many of
them are nonempty. -/
theorem countable_setOf_nonempty_of_disjoint {f : β → Set α}
    (hf : Pairwise (Disjoint on f)) {s : Set α} (h'f : ∀ t, f t ⊆ s) (hs : s.Countable) :
    Set.Countable {t | (f t).Nonempty} := by
  rw [← Set.countable_coe_iff] at hs ⊢
  have : ∀ t : {t // (f t).Nonempty}, ∃ x : s, x.1 ∈ f t := by
    rintro ⟨t, ⟨x, hx⟩⟩
    exact ⟨⟨x, (h'f t hx)⟩, hx⟩
  choose F hF using this
  have A : Injective F := by
    rintro ⟨t, ht⟩ ⟨t', ht'⟩ htt'
    

Proof state:
case mk.mk
α : Type u
β : Type v
γ : Type w
ι : Sort x
f : β → Set α
hf : Pairwise (Disjoint on f)
s : Set α
h'f : ∀ (t : β), f t ⊆ s
hs : Countable ↑s
F : { t // Set.Nonempty (f t) } → ↑s
hF : ∀ (t : { t // Set.Nonempty (f t) }), ↑(F t) ∈ f ↑t
t : β
ht : Set.Nonempty (f t)
t' : β
ht' : Set.Nonempty (f t')
htt' : F { val := t, property := ht } = F { val := t', property := ht' }
⊢ { val := t, property := ht } = { val := t', property := ht' }

Next tactic:
have A : (f t ∩ f t').Nonempty := by
      refine ⟨F ⟨t, ht⟩, hF _, ?_⟩
      rw [htt']
      exact hF _
/-- If a family of disjoint sets is included in a countable set, then only countably many of
them are nonempty. -/
theorem countable_setOf_nonempty_of_disjoint {f : β → Set α}
    (hf : Pairwise (Disjoint on f)) {s : Set α} (h'f : ∀ t, f t ⊆ s) (hs : s.Countable) :
    Set.Countable {t | (f t).Nonempty} := by
  rw [← Set.countable_coe_iff] at hs ⊢
  have : ∀ t : {t // (f t).Nonempty}, ∃ x : s, x.1 ∈ f t := by
    rintro ⟨t, ⟨x, hx⟩⟩
    exact ⟨⟨x, (h'f t hx)⟩, hx⟩
  choose F hF using this
  have A : Injective F := by
    rintro ⟨t, ht⟩ ⟨t', ht'⟩ htt'
    have A : (f t ∩ f t').Nonempty := by
      

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
f : β → Set α
hf : Pairwise (Disjoint on f)
s : Set α
h'f : ∀ (t : β), f t ⊆ s
hs : Countable ↑s
F : { t // Set.Nonempty (f t) } → ↑s
hF : ∀ (t : { t // Set.Nonempty (f t) }), ↑(F t) ∈ f ↑t
t : β
ht : Set.Nonempty (f t)
t' : β
ht' : Set.Nonempty (f t')
htt' : F { val := t, property := ht } = F { val := t', property := ht' }
⊢ Set.Nonempty (f t ∩ f t')

Next tactic:
refine ⟨F ⟨t, ht⟩, hF _, ?_⟩
/-- If a family of disjoint sets is included in a countable set, then only countably many of
them are nonempty. -/
theorem countable_setOf_nonempty_of_disjoint {f : β → Set α}
    (hf : Pairwise (Disjoint on f)) {s : Set α} (h'f : ∀ t, f t ⊆ s) (hs : s.Countable) :
    Set.Countable {t | (f t).Nonempty} := by
  rw [← Set.countable_coe_iff] at hs ⊢
  have : ∀ t : {t // (f t).Nonempty}, ∃ x : s, x.1 ∈ f t := by
    rintro ⟨t, ⟨x, hx⟩⟩
    exact ⟨⟨x, (h'f t hx)⟩, hx⟩
  choose F hF using this
  have A : Injective F := by
    rintro ⟨t, ht⟩ ⟨t', ht'⟩ htt'
    have A : (f t ∩ f t').Nonempty := by
      refine ⟨F ⟨t, ht⟩, hF _, ?_⟩
      

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
f : β → Set α
hf : Pairwise (Disjoint on f)
s : Set α
h'f : ∀ (t : β), f t ⊆ s
hs : Countable ↑s
F : { t // Set.Nonempty (f t) } → ↑s
hF : ∀ (t : { t // Set.Nonempty (f t) }), ↑(F t) ∈ f ↑t
t : β
ht : Set.Nonempty (f t)
t' : β
ht' : Set.Nonempty (f t')
htt' : F { val := t, property := ht } = F { val := t', property := ht' }
⊢ ↑(F { val := t, property := ht }) ∈ f t'

Next tactic:
rw [htt']
/-- If a family of disjoint sets is included in a countable set, then only countably many of
them are nonempty. -/
theorem countable_setOf_nonempty_of_disjoint {f : β → Set α}
    (hf : Pairwise (Disjoint on f)) {s : Set α} (h'f : ∀ t, f t ⊆ s) (hs : s.Countable) :
    Set.Countable {t | (f t).Nonempty} := by
  rw [← Set.countable_coe_iff] at hs ⊢
  have : ∀ t : {t // (f t).Nonempty}, ∃ x : s, x.1 ∈ f t := by
    rintro ⟨t, ⟨x, hx⟩⟩
    exact ⟨⟨x, (h'f t hx)⟩, hx⟩
  choose F hF using this
  have A : Injective F := by
    rintro ⟨t, ht⟩ ⟨t', ht'⟩ htt'
    have A : (f t ∩ f t').Nonempty := by
      refine ⟨F ⟨t, ht⟩, hF _, ?_⟩
      rw [htt']
      

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
f : β → Set α
hf : Pairwise (Disjoint on f)
s : Set α
h'f : ∀ (t : β), f t ⊆ s
hs : Countable ↑s
F : { t // Set.Nonempty (f t) } → ↑s
hF : ∀ (t : { t // Set.Nonempty (f t) }), ↑(F t) ∈ f ↑t
t : β
ht : Set.Nonempty (f t)
t' : β
ht' : Set.Nonempty (f t')
htt' : F { val := t, property := ht } = F { val := t', property := ht' }
⊢ ↑(F { val := t', property := ht' }) ∈ f t'

Next tactic:
exact hF _
/-- If a family of disjoint sets is included in a countable set, then only countably many of
them are nonempty. -/
theorem countable_setOf_nonempty_of_disjoint {f : β → Set α}
    (hf : Pairwise (Disjoint on f)) {s : Set α} (h'f : ∀ t, f t ⊆ s) (hs : s.Countable) :
    Set.Countable {t | (f t).Nonempty} := by
  rw [← Set.countable_coe_iff] at hs ⊢
  have : ∀ t : {t // (f t).Nonempty}, ∃ x : s, x.1 ∈ f t := by
    rintro ⟨t, ⟨x, hx⟩⟩
    exact ⟨⟨x, (h'f t hx)⟩, hx⟩
  choose F hF using this
  have A : Injective F := by
    rintro ⟨t, ht⟩ ⟨t', ht'⟩ htt'
    have A : (f t ∩ f t').Nonempty := by
      refine ⟨F ⟨t, ht⟩, hF _, ?_⟩
      rw [htt']
      exact hF _
    

Proof state:
case mk.mk
α : Type u
β : Type v
γ : Type w
ι : Sort x
f : β → Set α
hf : Pairwise (Disjoint on f)
s : Set α
h'f : ∀ (t : β), f t ⊆ s
hs : Countable ↑s
F : { t // Set.Nonempty (f t) } → ↑s
hF : ∀ (t : { t // Set.Nonempty (f t) }), ↑(F t) ∈ f ↑t
t : β
ht : Set.Nonempty (f t)
t' : β
ht' : Set.Nonempty (f t')
htt' : F { val := t, property := ht } = F { val := t', property := ht' }
A : Set.Nonempty (f t ∩ f t')
⊢ { val := t, property := ht } = { val := t', property := ht' }

Next tactic:
simp only [Subtype.mk.injEq]