l3lab/ntp-mathlib huggingface dataset:
/-- `image2 f s t` is `Fintype` if `s` and `t` are. -/
instance fintypeImage2 [DecidableEq γ] (f : α → β → γ) (s : Set α) (t : Set β) [hs : Fintype s]
    [ht : Fintype t] : Fintype (image2 f s t : Set γ) := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
inst✝ : DecidableEq γ
f : α → β → γ
s : Set α
t : Set β
hs : Fintype ↑s
ht : Fintype ↑t
⊢ Fintype ↑(image2 f s t)

Next tactic:
rw [← image_prod]
/-- `image2 f s t` is `Fintype` if `s` and `t` are. -/
instance fintypeImage2 [DecidableEq γ] (f : α → β → γ) (s : Set α) (t : Set β) [hs : Fintype s]
    [ht : Fintype t] : Fintype (image2 f s t : Set γ) := by
  rw [← image_prod]
  

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

Next tactic:
apply Set.fintypeImage
instance fintypeSeq [DecidableEq β] (f : Set (α → β)) (s : Set α) [Fintype f] [Fintype s] :
    Fintype (f.seq s) := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
inst✝² : DecidableEq β
f : Set (α → β)
s : Set α
inst✝¹ : Fintype ↑f
inst✝ : Fintype ↑s
⊢ Fintype ↑(seq f s)

Next tactic:
rw [seq_def]
instance fintypeSeq [DecidableEq β] (f : Set (α → β)) (s : Set α) [Fintype f] [Fintype s] :
    Fintype (f.seq s) := by
  rw [seq_def]
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
inst✝² : DecidableEq β
f : Set (α → β)
s : Set α
inst✝¹ : Fintype ↑f
inst✝ : Fintype ↑s
⊢ Fintype ↑(⋃ f_1 ∈ f, f_1 '' s)

Next tactic:
apply Set.fintypeBiUnion'
theorem Equiv.set_finite_iff {s : Set α} {t : Set β} (hst : s ≃ t) : s.Finite ↔ t.Finite := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
t : Set β
hst : ↑s ≃ ↑t
⊢ Set.Finite s ↔ Set.Finite t

Next tactic:
simp_rw [← Set.finite_coe_iff, hst.finite_iff]
theorem finite_toSet_toFinset (s : Finset α) : s.finite_toSet.toFinset = s := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Finset α
⊢ Finite.toFinset (_ : Set.Finite ↑s) = s

Next tactic:
rw [toFinite_toFinset, toFinset_coe]
@[simp]
theorem finite_toSet (s : Multiset α) : { x | x ∈ s }.Finite := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Multiset α
⊢ Set.Finite {x | x ∈ s}

Next tactic:
classical simpa only [← Multiset.mem_toFinset] using s.toFinset.finite_toSet
@[simp]
theorem finite_toSet (s : Multiset α) : { x | x ∈ s }.Finite := by
  classical 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Multiset α
⊢ Set.Finite {x | x ∈ s}

Next tactic:
simpa only [← Multiset.mem_toFinset] using s.toFinset.finite_toSet
@[simp]
theorem finite_toSet_toFinset [DecidableEq α] (s : Multiset α) :
    s.finite_toSet.toFinset = s.toFinset := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
inst✝ : DecidableEq α
s : Multiset α
⊢ Finite.toFinset (_ : Set.Finite {x | x ∈ s}) = toFinset s

Next tactic:
ext x
@[simp]
theorem finite_toSet_toFinset [DecidableEq α] (s : Multiset α) :
    s.finite_toSet.toFinset = s.toFinset := by
  ext x
  

Proof state:
case a
α : Type u
β : Type v
ι : Sort w
γ : Type x
inst✝ : DecidableEq α
s : Multiset α
x : α
⊢ x ∈ Finite.toFinset (_ : Set.Finite {x | x ∈ s}) ↔ x ∈ toFinset s

Next tactic:
simp
instance finite_union (s t : Set α) [Finite s] [Finite t] : Finite (s ∪ t : Set α) := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
inst✝¹ : Finite ↑s
inst✝ : Finite ↑t
⊢ Finite ↑(s ∪ t)

Next tactic:
cases nonempty_fintype s
instance finite_union (s t : Set α) [Finite s] [Finite t] : Finite (s ∪ t : Set α) := by
  cases nonempty_fintype s
  

Proof state:
case intro
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
inst✝¹ : Finite ↑s
inst✝ : Finite ↑t
val✝ : Fintype ↑s
⊢ Finite ↑(s ∪ t)

Next tactic:
cases nonempty_fintype t
instance finite_union (s t : Set α) [Finite s] [Finite t] : Finite (s ∪ t : Set α) := by
  cases nonempty_fintype s
  cases nonempty_fintype t
  

Proof state:
case intro.intro
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
inst✝¹ : Finite ↑s
inst✝ : Finite ↑t
val✝¹ : Fintype ↑s
val✝ : Fintype ↑t
⊢ Finite ↑(s ∪ t)

Next tactic:
infer_instance
instance finite_sep (s : Set α) (p : α → Prop) [Finite s] : Finite ({ a ∈ s | p a } : Set α) := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
p : α → Prop
inst✝ : Finite ↑s
⊢ Finite ↑{a | a ∈ s ∧ p a}

Next tactic:
cases nonempty_fintype s
instance finite_sep (s : Set α) (p : α → Prop) [Finite s] : Finite ({ a ∈ s | p a } : Set α) := by
  cases nonempty_fintype s
  

Proof state:
case intro
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
p : α → Prop
inst✝ : Finite ↑s
val✝ : Fintype ↑s
⊢ Finite ↑{a | a ∈ s ∧ p a}

Next tactic:
infer_instance
protected theorem subset (s : Set α) {t : Set α} [Finite s] (h : t ⊆ s) : Finite t := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
inst✝ : Finite ↑s
h : t ⊆ s
⊢ Finite ↑t

Next tactic:
rw [← sep_eq_of_subset h]
protected theorem subset (s : Set α) {t : Set α} [Finite s] (h : t ⊆ s) : Finite t := by
  rw [← sep_eq_of_subset h]
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
inst✝ : Finite ↑s
h : t ⊆ s
⊢ Finite ↑{x | x ∈ s ∧ x ∈ t}

Next tactic:
infer_instance
instance finite_range (f : ι → α) [Finite ι] : Finite (range f) := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
f : ι → α
inst✝ : Finite ι
⊢ Finite ↑(range f)

Next tactic:
haveI := Fintype.ofFinite (PLift ι)
instance finite_range (f : ι → α) [Finite ι] : Finite (range f) := by
  haveI := Fintype.ofFinite (PLift ι)
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
f : ι → α
inst✝ : Finite ι
this : Fintype (PLift ι)
⊢ Finite ↑(range f)

Next tactic:
infer_instance
instance finite_iUnion [Finite ι] (f : ι → Set α) [∀ i, Finite (f i)] : Finite (⋃ i, f i) := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
inst✝¹ : Finite ι
f : ι → Set α
inst✝ : ∀ (i : ι), Finite ↑(f i)
⊢ Finite ↑(⋃ i, f i)

Next tactic:
rw [iUnion_eq_range_psigma]
instance finite_iUnion [Finite ι] (f : ι → Set α) [∀ i, Finite (f i)] : Finite (⋃ i, f i) := by
  rw [iUnion_eq_range_psigma]
  

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

Next tactic:
apply Set.finite_range
instance finite_sUnion {s : Set (Set α)} [Finite s] [H : ∀ t : s, Finite (t : Set α)] :
    Finite (⋃₀ s) := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set (Set α)
inst✝ : Finite ↑s
H : ∀ (t : ↑s), Finite ↑↑t
⊢ Finite ↑(⋃₀ s)

Next tactic:
rw [sUnion_eq_iUnion]
instance finite_sUnion {s : Set (Set α)} [Finite s] [H : ∀ t : s, Finite (t : Set α)] :
    Finite (⋃₀ s) := by
  rw [sUnion_eq_iUnion]
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set (Set α)
inst✝ : Finite ↑s
H : ∀ (t : ↑s), Finite ↑↑t
⊢ Finite ↑(⋃ i, ↑i)

Next tactic:
exact @Finite.Set.finite_iUnion _ _ _ _ H
theorem finite_biUnion {ι : Type*} (s : Set ι) [Finite s] (t : ι → Set α)
    (H : ∀ i ∈ s, Finite (t i)) : Finite (⋃ x ∈ s, t x) := by
  

Proof state:
α : Type u
β : Type v
ι✝ : Sort w
γ : Type x
ι : Type u_1
s : Set ι
inst✝ : Finite ↑s
t : ι → Set α
H : ∀ i ∈ s, Finite ↑(t i)
⊢ Finite ↑(⋃ x ∈ s, t x)

Next tactic:
rw [biUnion_eq_iUnion]
theorem finite_biUnion {ι : Type*} (s : Set ι) [Finite s] (t : ι → Set α)
    (H : ∀ i ∈ s, Finite (t i)) : Finite (⋃ x ∈ s, t x) := by
  rw [biUnion_eq_iUnion]
  

Proof state:
α : Type u
β : Type v
ι✝ : Sort w
γ : Type x
ι : Type u_1
s : Set ι
inst✝ : Finite ↑s
t : ι → Set α
H : ∀ i ∈ s, Finite ↑(t i)
⊢ Finite ↑(⋃ x, t ↑x)

Next tactic:
haveI : ∀ i : s, Finite (t i) := fun i => H i i.property
theorem finite_biUnion {ι : Type*} (s : Set ι) [Finite s] (t : ι → Set α)
    (H : ∀ i ∈ s, Finite (t i)) : Finite (⋃ x ∈ s, t x) := by
  rw [biUnion_eq_iUnion]
  haveI : ∀ i : s, Finite (t i) := fun i => H i i.property
  

Proof state:
α : Type u
β : Type v
ι✝ : Sort w
γ : Type x
ι : Type u_1
s : Set ι
inst✝ : Finite ↑s
t : ι → Set α
H : ∀ i ∈ s, Finite ↑(t i)
this : ∀ (i : ↑s), Finite ↑(t ↑i)
⊢ Finite ↑(⋃ x, t ↑x)

Next tactic:
infer_instance
instance finite_image (s : Set α) (f : α → β) [Finite s] : Finite (f '' s) := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
f : α → β
inst✝ : Finite ↑s
⊢ Finite ↑(f '' s)

Next tactic:
cases nonempty_fintype s
instance finite_image (s : Set α) (f : α → β) [Finite s] : Finite (f '' s) := by
  cases nonempty_fintype s
  

Proof state:
case intro
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
f : α → β
inst✝ : Finite ↑s
val✝ : Fintype ↑s
⊢ Finite ↑(f '' s)

Next tactic:
infer_instance
instance finite_image2 (f : α → β → γ) (s : Set α) (t : Set β) [Finite s] [Finite t] :
    Finite (image2 f s t : Set γ) := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
f : α → β → γ
s : Set α
t : Set β
inst✝¹ : Finite ↑s
inst✝ : Finite ↑t
⊢ Finite ↑(image2 f s t)

Next tactic:
rw [← image_prod]
instance finite_image2 (f : α → β → γ) (s : Set α) (t : Set β) [Finite s] [Finite t] :
    Finite (image2 f s t : Set γ) := by
  rw [← image_prod]
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
f : α → β → γ
s : Set α
t : Set β
inst✝¹ : Finite ↑s
inst✝ : Finite ↑t
⊢ Finite ↑((fun x => f x.1 x.2) '' s ×ˢ t)

Next tactic:
infer_instance
instance finite_seq (f : Set (α → β)) (s : Set α) [Finite f] [Finite s] : Finite (f.seq s) := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
f : Set (α → β)
s : Set α
inst✝¹ : Finite ↑f
inst✝ : Finite ↑s
⊢ Finite ↑(seq f s)

Next tactic:
rw [seq_def]
instance finite_seq (f : Set (α → β)) (s : Set α) [Finite f] [Finite s] : Finite (f.seq s) := by
  rw [seq_def]
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
f : Set (α → β)
s : Set α
inst✝¹ : Finite ↑f
inst✝ : Finite ↑s
⊢ Finite ↑(⋃ f_1 ∈ f, f_1 '' s)

Next tactic:
infer_instance
theorem Finite.union {s t : Set α} (hs : s.Finite) (ht : t.Finite) : (s ∪ t).Finite := by
  

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

Next tactic:
cases hs
theorem Finite.union {s t : Set α} (hs : s.Finite) (ht : t.Finite) : (s ∪ t).Finite := by
  cases hs
  

Proof state:
case intro
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
ht : Set.Finite t
a✝ : Fintype ↑s
⊢ Set.Finite (s ∪ t)

Next tactic:
cases ht
theorem Finite.union {s t : Set α} (hs : s.Finite) (ht : t.Finite) : (s ∪ t).Finite := by
  cases hs
  cases ht
  

Proof state:
case intro.intro
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a✝¹ : Fintype ↑s
a✝ : Fintype ↑t
⊢ Set.Finite (s ∪ t)

Next tactic:
apply toFinite
theorem Finite.finite_of_compl {s : Set α} (hs : s.Finite) (hsc : sᶜ.Finite) : Finite α := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
hs : Set.Finite s
hsc : Set.Finite sᶜ
⊢ Finite α

Next tactic:
rw [← finite_univ_iff, ← union_compl_self s]
theorem Finite.finite_of_compl {s : Set α} (hs : s.Finite) (hsc : sᶜ.Finite) : Finite α := by
  rw [← finite_univ_iff, ← union_compl_self s]
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
hs : Set.Finite s
hsc : Set.Finite sᶜ
⊢ Set.Finite (s ∪ sᶜ)

Next tactic:
exact hs.union hsc
theorem Finite.sep {s : Set α} (hs : s.Finite) (p : α → Prop) : { a ∈ s | p a }.Finite := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
hs : Set.Finite s
p : α → Prop
⊢ Set.Finite {a | a ∈ s ∧ p a}

Next tactic:
cases hs
theorem Finite.sep {s : Set α} (hs : s.Finite) (p : α → Prop) : { a ∈ s | p a }.Finite := by
  cases hs
  

Proof state:
case intro
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
p : α → Prop
a✝ : Fintype ↑s
⊢ Set.Finite {a | a ∈ s ∧ p a}

Next tactic:
apply toFinite
theorem Finite.inter_of_left {s : Set α} (hs : s.Finite) (t : Set α) : (s ∩ t).Finite := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
hs : Set.Finite s
t : Set α
⊢ Set.Finite (s ∩ t)

Next tactic:
cases hs
theorem Finite.inter_of_left {s : Set α} (hs : s.Finite) (t : Set α) : (s ∩ t).Finite := by
  cases hs
  

Proof state:
case intro
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a✝ : Fintype ↑s
⊢ Set.Finite (s ∩ t)

Next tactic:
apply toFinite
theorem Finite.inter_of_right {s : Set α} (hs : s.Finite) (t : Set α) : (t ∩ s).Finite := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
hs : Set.Finite s
t : Set α
⊢ Set.Finite (t ∩ s)

Next tactic:
cases hs
theorem Finite.inter_of_right {s : Set α} (hs : s.Finite) (t : Set α) : (t ∩ s).Finite := by
  cases hs
  

Proof state:
case intro
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a✝ : Fintype ↑s
⊢ Set.Finite (t ∩ s)

Next tactic:
apply toFinite
theorem Finite.subset {s : Set α} (hs : s.Finite) {t : Set α} (ht : t ⊆ s) : t.Finite := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
hs : Set.Finite s
t : Set α
ht : t ⊆ s
⊢ Set.Finite t

Next tactic:
cases hs
theorem Finite.subset {s : Set α} (hs : s.Finite) {t : Set α} (ht : t ⊆ s) : t.Finite := by
  cases hs
  

Proof state:
case intro
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
ht : t ⊆ s
a✝ : Fintype ↑s
⊢ Set.Finite t

Next tactic:
haveI := Finite.Set.subset _ ht
theorem Finite.subset {s : Set α} (hs : s.Finite) {t : Set α} (ht : t ⊆ s) : t.Finite := by
  cases hs
  haveI := Finite.Set.subset _ ht
  

Proof state:
case intro
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
ht : t ⊆ s
a✝ : Fintype ↑s
this : Finite ↑t
⊢ Set.Finite t

Next tactic:
apply toFinite
theorem Finite.diff {s : Set α} (hs : s.Finite) (t : Set α) : (s \ t).Finite := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
hs : Set.Finite s
t : Set α
⊢ Set.Finite (s \ t)

Next tactic:
cases hs
theorem Finite.diff {s : Set α} (hs : s.Finite) (t : Set α) : (s \ t).Finite := by
  cases hs
  

Proof state:
case intro
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a✝ : Fintype ↑s
⊢ Set.Finite (s \ t)

Next tactic:
apply toFinite
theorem finite_iUnion [Finite ι] {f : ι → Set α} (H : ∀ i, (f i).Finite) : (⋃ i, f i).Finite := by
  

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

Next tactic:
haveI := fun i => (H i).fintype
theorem finite_iUnion [Finite ι] {f : ι → Set α} (H : ∀ i, (f i).Finite) : (⋃ i, f i).Finite := by
  haveI := fun i => (H i).fintype
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
inst✝ : Finite ι
f : ι → Set α
H : ∀ (i : ι), Set.Finite (f i)
this : (i : ι) → Fintype ↑(f i)
⊢ Set.Finite (⋃ i, f i)

Next tactic:
apply toFinite
theorem Finite.sUnion {s : Set (Set α)} (hs : s.Finite) (H : ∀ t ∈ s, Set.Finite t) :
    (⋃₀ s).Finite := by
  

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

Next tactic:
cases hs
theorem Finite.sUnion {s : Set (Set α)} (hs : s.Finite) (H : ∀ t ∈ s, Set.Finite t) :
    (⋃₀ s).Finite := by
  cases hs
  

Proof state:
case intro
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set (Set α)
H : ∀ t ∈ s, Set.Finite t
a✝ : Fintype ↑s
⊢ Set.Finite (⋃₀ s)

Next tactic:
haveI := fun i : s => (H i i.2).to_subtype
theorem Finite.sUnion {s : Set (Set α)} (hs : s.Finite) (H : ∀ t ∈ s, Set.Finite t) :
    (⋃₀ s).Finite := by
  cases hs
  haveI := fun i : s => (H i i.2).to_subtype
  

Proof state:
case intro
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set (Set α)
H : ∀ t ∈ s, Set.Finite t
a✝ : Fintype ↑s
this : ∀ (i : ↑s), Finite ↑↑i
⊢ Set.Finite (⋃₀ s)

Next tactic:
apply toFinite
theorem Finite.biUnion {ι} {s : Set ι} (hs : s.Finite) {t : ι → Set α}
    (ht : ∀ i ∈ s, (t i).Finite) : (⋃ i ∈ s, t i).Finite := by
  

Proof state:
α : Type u
β : Type v
ι✝ : Sort w
γ : Type x
ι : Type u_1
s : Set ι
hs : Set.Finite s
t : ι → Set α
ht : ∀ i ∈ s, Set.Finite (t i)
⊢ Set.Finite (⋃ i ∈ s, t i)

Next tactic:
classical
    cases hs
    haveI := fintypeBiUnion s t fun i hi => (ht i hi).fintype
    apply toFinite
theorem Finite.biUnion {ι} {s : Set ι} (hs : s.Finite) {t : ι → Set α}
    (ht : ∀ i ∈ s, (t i).Finite) : (⋃ i ∈ s, t i).Finite := by
  classical
    

Proof state:
α : Type u
β : Type v
ι✝ : Sort w
γ : Type x
ι : Type u_1
s : Set ι
hs : Set.Finite s
t : ι → Set α
ht : ∀ i ∈ s, Set.Finite (t i)
⊢ Set.Finite (⋃ i ∈ s, t i)

Next tactic:
cases hs
theorem Finite.biUnion {ι} {s : Set ι} (hs : s.Finite) {t : ι → Set α}
    (ht : ∀ i ∈ s, (t i).Finite) : (⋃ i ∈ s, t i).Finite := by
  classical
    cases hs
    

Proof state:
case intro
α : Type u
β : Type v
ι✝ : Sort w
γ : Type x
ι : Type u_1
s : Set ι
t : ι → Set α
ht : ∀ i ∈ s, Set.Finite (t i)
a✝ : Fintype ↑s
⊢ Set.Finite (⋃ i ∈ s, t i)

Next tactic:
haveI := fintypeBiUnion s t fun i hi => (ht i hi).fintype
theorem Finite.biUnion {ι} {s : Set ι} (hs : s.Finite) {t : ι → Set α}
    (ht : ∀ i ∈ s, (t i).Finite) : (⋃ i ∈ s, t i).Finite := by
  classical
    cases hs
    haveI := fintypeBiUnion s t fun i hi => (ht i hi).fintype
    

Proof state:
case intro
α : Type u
β : Type v
ι✝ : Sort w
γ : Type x
ι : Type u_1
s : Set ι
t : ι → Set α
ht : ∀ i ∈ s, Set.Finite (t i)
a✝ : Fintype ↑s
this : Fintype ↑(⋃ x ∈ s, t x)
⊢ Set.Finite (⋃ i ∈ s, t i)

Next tactic:
apply toFinite
/-- Dependent version of `Finite.biUnion`. -/
theorem Finite.biUnion' {ι} {s : Set ι} (hs : s.Finite) {t : ∀ i ∈ s, Set α}
    (ht : ∀ i (hi : i ∈ s), (t i hi).Finite) : (⋃ i ∈ s, t i ‹_›).Finite := by
  

Proof state:
α : Type u
β : Type v
ι✝ : Sort w
γ : Type x
ι : Type u_1
s : Set ι
hs : Set.Finite s
t : (i : ι) → i ∈ s → Set α
ht : ∀ (i : ι) (hi : i ∈ s), Set.Finite (t i hi)
⊢ Set.Finite (⋃ i, ⋃ (h : i ∈ s), t i h)

Next tactic:
cases hs
/-- Dependent version of `Finite.biUnion`. -/
theorem Finite.biUnion' {ι} {s : Set ι} (hs : s.Finite) {t : ∀ i ∈ s, Set α}
    (ht : ∀ i (hi : i ∈ s), (t i hi).Finite) : (⋃ i ∈ s, t i ‹_›).Finite := by
  cases hs
  

Proof state:
case intro
α : Type u
β : Type v
ι✝ : Sort w
γ : Type x
ι : Type u_1
s : Set ι
t : (i : ι) → i ∈ s → Set α
ht : ∀ (i : ι) (hi : i ∈ s), Set.Finite (t i hi)
a✝ : Fintype ↑s
⊢ Set.Finite (⋃ i, ⋃ (h : i ∈ s), t i h)

Next tactic:
rw [biUnion_eq_iUnion]
/-- Dependent version of `Finite.biUnion`. -/
theorem Finite.biUnion' {ι} {s : Set ι} (hs : s.Finite) {t : ∀ i ∈ s, Set α}
    (ht : ∀ i (hi : i ∈ s), (t i hi).Finite) : (⋃ i ∈ s, t i ‹_›).Finite := by
  cases hs
  rw [biUnion_eq_iUnion]
  

Proof state:
case intro
α : Type u
β : Type v
ι✝ : Sort w
γ : Type x
ι : Type u_1
s : Set ι
t : (i : ι) → i ∈ s → Set α
ht : ∀ (i : ι) (hi : i ∈ s), Set.Finite (t i hi)
a✝ : Fintype ↑s
⊢ Set.Finite (⋃ x, t ↑x (_ : ↑x ∈ s))

Next tactic:
apply finite_iUnion fun i : s => ht i.1 i.2
/-- If sets `s i` are finite for all `i` from a finite set `t` and are empty for `i ∉ t`, then the
union `⋃ i, s i` is a finite set. -/
theorem Finite.iUnion {ι : Type*} {s : ι → Set α} {t : Set ι} (ht : t.Finite)
    (hs : ∀ i ∈ t, (s i).Finite) (he : ∀ i, i ∉ t → s i = ∅) : (⋃ i, s i).Finite := by
  

Proof state:
α : Type u
β : Type v
ι✝ : Sort w
γ : Type x
ι : Type u_1
s : ι → Set α
t : Set ι
ht : Set.Finite t
hs : ∀ i ∈ t, Set.Finite (s i)
he : ∀ i ∉ t, s i = ∅
⊢ Set.Finite (⋃ i, s i)

Next tactic:
suffices ⋃ i, s i ⊆ ⋃ i ∈ t, s i by exact (ht.biUnion hs).subset this
/-- If sets `s i` are finite for all `i` from a finite set `t` and are empty for `i ∉ t`, then the
union `⋃ i, s i` is a finite set. -/
theorem Finite.iUnion {ι : Type*} {s : ι → Set α} {t : Set ι} (ht : t.Finite)
    (hs : ∀ i ∈ t, (s i).Finite) (he : ∀ i, i ∉ t → s i = ∅) : (⋃ i, s i).Finite := by
  suffices ⋃ i, s i ⊆ ⋃ i ∈ t, s i by 

Proof state:
α : Type u
β : Type v
ι✝ : Sort w
γ : Type x
ι : Type u_1
s : ι → Set α
t : Set ι
ht : Set.Finite t
hs : ∀ i ∈ t, Set.Finite (s i)
he : ∀ i ∉ t, s i = ∅
this : ⋃ i, s i ⊆ ⋃ i ∈ t, s i
⊢ Set.Finite (⋃ i, s i)

Next tactic:
exact (ht.biUnion hs).subset this
/-- If sets `s i` are finite for all `i` from a finite set `t` and are empty for `i ∉ t`, then the
union `⋃ i, s i` is a finite set. -/
theorem Finite.iUnion {ι : Type*} {s : ι → Set α} {t : Set ι} (ht : t.Finite)
    (hs : ∀ i ∈ t, (s i).Finite) (he : ∀ i, i ∉ t → s i = ∅) : (⋃ i, s i).Finite := by
  suffices ⋃ i, s i ⊆ ⋃ i ∈ t, s i by exact (ht.biUnion hs).subset this
  

Proof state:
α : Type u
β : Type v
ι✝ : Sort w
γ : Type x
ι : Type u_1
s : ι → Set α
t : Set ι
ht : Set.Finite t
hs : ∀ i ∈ t, Set.Finite (s i)
he : ∀ i ∉ t, s i = ∅
⊢ ⋃ i, s i ⊆ ⋃ i ∈ t, s i

Next tactic:
refine' iUnion_subset fun i x hx => _
/-- If sets `s i` are finite for all `i` from a finite set `t` and are empty for `i ∉ t`, then the
union `⋃ i, s i` is a finite set. -/
theorem Finite.iUnion {ι : Type*} {s : ι → Set α} {t : Set ι} (ht : t.Finite)
    (hs : ∀ i ∈ t, (s i).Finite) (he : ∀ i, i ∉ t → s i = ∅) : (⋃ i, s i).Finite := by
  suffices ⋃ i, s i ⊆ ⋃ i ∈ t, s i by exact (ht.biUnion hs).subset this
  refine' iUnion_subset fun i x hx => _
  

Proof state:
α : Type u
β : Type v
ι✝ : Sort w
γ : Type x
ι : Type u_1
s : ι → Set α
t : Set ι
ht : Set.Finite t
hs : ∀ i ∈ t, Set.Finite (s i)
he : ∀ i ∉ t, s i = ∅
i : ι
x : α
hx : x ∈ s i
⊢ x ∈ ⋃ i ∈ t, s i

Next tactic:
by_cases hi : i ∈ t
/-- If sets `s i` are finite for all `i` from a finite set `t` and are empty for `i ∉ t`, then the
union `⋃ i, s i` is a finite set. -/
theorem Finite.iUnion {ι : Type*} {s : ι → Set α} {t : Set ι} (ht : t.Finite)
    (hs : ∀ i ∈ t, (s i).Finite) (he : ∀ i, i ∉ t → s i = ∅) : (⋃ i, s i).Finite := by
  suffices ⋃ i, s i ⊆ ⋃ i ∈ t, s i by exact (ht.biUnion hs).subset this
  refine' iUnion_subset fun i x hx => _
  by_cases hi : i ∈ t
  · 

Proof state:
case pos
α : Type u
β : Type v
ι✝ : Sort w
γ : Type x
ι : Type u_1
s : ι → Set α
t : Set ι
ht : Set.Finite t
hs : ∀ i ∈ t, Set.Finite (s i)
he : ∀ i ∉ t, s i = ∅
i : ι
x : α
hx : x ∈ s i
hi : i ∈ t
⊢ x ∈ ⋃ i ∈ t, s i

Next tactic:
exact mem_biUnion hi hx
/-- If sets `s i` are finite for all `i` from a finite set `t` and are empty for `i ∉ t`, then the
union `⋃ i, s i` is a finite set. -/
theorem Finite.iUnion {ι : Type*} {s : ι → Set α} {t : Set ι} (ht : t.Finite)
    (hs : ∀ i ∈ t, (s i).Finite) (he : ∀ i, i ∉ t → s i = ∅) : (⋃ i, s i).Finite := by
  suffices ⋃ i, s i ⊆ ⋃ i ∈ t, s i by exact (ht.biUnion hs).subset this
  refine' iUnion_subset fun i x hx => _
  by_cases hi : i ∈ t
  · exact mem_biUnion hi hx
  · 

Proof state:
case neg
α : Type u
β : Type v
ι✝ : Sort w
γ : Type x
ι : Type u_1
s : ι → Set α
t : Set ι
ht : Set.Finite t
hs : ∀ i ∈ t, Set.Finite (s i)
he : ∀ i ∉ t, s i = ∅
i : ι
x : α
hx : x ∈ s i
hi : i ∉ t
⊢ x ∈ ⋃ i ∈ t, s i

Next tactic:
rw [he i hi, mem_empty_iff_false] at hx
/-- If sets `s i` are finite for all `i` from a finite set `t` and are empty for `i ∉ t`, then the
union `⋃ i, s i` is a finite set. -/
theorem Finite.iUnion {ι : Type*} {s : ι → Set α} {t : Set ι} (ht : t.Finite)
    (hs : ∀ i ∈ t, (s i).Finite) (he : ∀ i, i ∉ t → s i = ∅) : (⋃ i, s i).Finite := by
  suffices ⋃ i, s i ⊆ ⋃ i ∈ t, s i by exact (ht.biUnion hs).subset this
  refine' iUnion_subset fun i x hx => _
  by_cases hi : i ∈ t
  · exact mem_biUnion hi hx
  · rw [he i hi, mem_empty_iff_false] at hx
    

Proof state:
case neg
α : Type u
β : Type v
ι✝ : Sort w
γ : Type x
ι : Type u_1
s : ι → Set α
t : Set ι
ht : Set.Finite t
hs : ∀ i ∈ t, Set.Finite (s i)
he : ∀ i ∉ t, s i = ∅
i : ι
x : α
hx : False
hi : i ∉ t
⊢ x ∈ ⋃ i ∈ t, s i

Next tactic:
contradiction
protected theorem Infinite.nonempty {s : Set α} (h : s.Infinite) : s.Nonempty :=
  nonempty_iff_ne_empty.2 $ by
    

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
h : Set.Infinite s
⊢ s ≠ ∅

Next tactic:
rintro rfl
protected theorem Infinite.nonempty {s : Set α} (h : s.Infinite) : s.Nonempty :=
  nonempty_iff_ne_empty.2 $ by
    rintro rfl
    

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
h : Set.Infinite ∅
⊢ False

Next tactic:
exact h finite_empty
@[simp]
protected theorem Finite.insert (a : α) {s : Set α} (hs : s.Finite) : (insert a s).Finite := by
  

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

Next tactic:
cases hs