l3lab/ntp-mathlib huggingface dataset:
@[simp]
theorem toFinset_subset {t : Finset α} : hs.toFinset ⊆ t ↔ s ⊆ t := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t✝ : Set α
a : α
hs : Set.Finite s
ht : Set.Finite t✝
t : Finset α
⊢ Finite.toFinset hs ⊆ t ↔ s ⊆ ↑t

Next tactic:
rw [← Finset.coe_subset, Finite.coe_toFinset]
@[simp]
theorem toFinset_ssubset {t : Finset α} : hs.toFinset ⊂ t ↔ s ⊂ t := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t✝ : Set α
a : α
hs : Set.Finite s
ht : Set.Finite t✝
t : Finset α
⊢ Finite.toFinset hs ⊂ t ↔ s ⊂ ↑t

Next tactic:
rw [← Finset.coe_ssubset, Finite.coe_toFinset]
@[simp]
theorem subset_toFinset {s : Finset α} : s ⊆ ht.toFinset ↔ ↑s ⊆ t := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s✝ t : Set α
a : α
hs : Set.Finite s✝
ht : Set.Finite t
s : Finset α
⊢ s ⊆ Finite.toFinset ht ↔ ↑s ⊆ t

Next tactic:
rw [← Finset.coe_subset, Finite.coe_toFinset]
@[simp]
theorem ssubset_toFinset {s : Finset α} : s ⊂ ht.toFinset ↔ ↑s ⊂ t := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s✝ t : Set α
a : α
hs : Set.Finite s✝
ht : Set.Finite t
s : Finset α
⊢ s ⊂ Finite.toFinset ht ↔ ↑s ⊂ t

Next tactic:
rw [← Finset.coe_ssubset, Finite.coe_toFinset]
@[mono]
protected theorem toFinset_subset_toFinset : hs.toFinset ⊆ ht.toFinset ↔ s ⊆ t := by
  

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

Next tactic:
simp only [← Finset.coe_subset, Finite.coe_toFinset]
@[mono]
protected theorem toFinset_ssubset_toFinset : hs.toFinset ⊂ ht.toFinset ↔ s ⊂ t := by
  

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

Next tactic:
simp only [← Finset.coe_ssubset, Finite.coe_toFinset]
@[simp high]
protected theorem toFinset_setOf [Fintype α] (p : α → Prop) [DecidablePred p]
    (h : { x | p x }.Finite) : h.toFinset = Finset.univ.filter p := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a : α
hs : Set.Finite s
ht : Set.Finite t
inst✝¹ : Fintype α
p : α → Prop
inst✝ : DecidablePred p
h : Set.Finite {x | p x}
⊢ Finite.toFinset h = Finset.filter p Finset.univ

Next tactic:
ext
@[simp high]
protected theorem toFinset_setOf [Fintype α] (p : α → Prop) [DecidablePred p]
    (h : { x | p x }.Finite) : h.toFinset = Finset.univ.filter p := by
  ext
  -- porting note: `simp` doesn't use the `simp` lemma `Set.toFinset_setOf` without the `_`
  

Proof state:
case a
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a : α
hs : Set.Finite s
ht : Set.Finite t
inst✝¹ : Fintype α
p : α → Prop
inst✝ : DecidablePred p
h : Set.Finite {x | p x}
a✝ : α
⊢ a✝ ∈ Finite.toFinset h ↔ a✝ ∈ Finset.filter p Finset.univ

Next tactic:
simp [Set.toFinset_setOf _]
protected theorem toFinset_inter [DecidableEq α] (hs : s.Finite) (ht : t.Finite)
    (h : (s ∩ t).Finite) : h.toFinset = hs.toFinset ∩ ht.toFinset := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a : α
hs✝ : Set.Finite s
ht✝ : Set.Finite t
inst✝ : DecidableEq α
hs : Set.Finite s
ht : Set.Finite t
h : Set.Finite (s ∩ t)
⊢ Finite.toFinset h = Finite.toFinset hs ∩ Finite.toFinset ht

Next tactic:
ext
protected theorem toFinset_inter [DecidableEq α] (hs : s.Finite) (ht : t.Finite)
    (h : (s ∩ t).Finite) : h.toFinset = hs.toFinset ∩ ht.toFinset := by
  ext
  

Proof state:
case a
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a : α
hs✝ : Set.Finite s
ht✝ : Set.Finite t
inst✝ : DecidableEq α
hs : Set.Finite s
ht : Set.Finite t
h : Set.Finite (s ∩ t)
a✝ : α
⊢ a✝ ∈ Finite.toFinset h ↔ a✝ ∈ Finite.toFinset hs ∩ Finite.toFinset ht

Next tactic:
simp
protected theorem toFinset_union [DecidableEq α] (hs : s.Finite) (ht : t.Finite)
    (h : (s ∪ t).Finite) : h.toFinset = hs.toFinset ∪ ht.toFinset := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a : α
hs✝ : Set.Finite s
ht✝ : Set.Finite t
inst✝ : DecidableEq α
hs : Set.Finite s
ht : Set.Finite t
h : Set.Finite (s ∪ t)
⊢ Finite.toFinset h = Finite.toFinset hs ∪ Finite.toFinset ht

Next tactic:
ext
protected theorem toFinset_union [DecidableEq α] (hs : s.Finite) (ht : t.Finite)
    (h : (s ∪ t).Finite) : h.toFinset = hs.toFinset ∪ ht.toFinset := by
  ext
  

Proof state:
case a
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a : α
hs✝ : Set.Finite s
ht✝ : Set.Finite t
inst✝ : DecidableEq α
hs : Set.Finite s
ht : Set.Finite t
h : Set.Finite (s ∪ t)
a✝ : α
⊢ a✝ ∈ Finite.toFinset h ↔ a✝ ∈ Finite.toFinset hs ∪ Finite.toFinset ht

Next tactic:
simp
protected theorem toFinset_diff [DecidableEq α] (hs : s.Finite) (ht : t.Finite)
    (h : (s \ t).Finite) : h.toFinset = hs.toFinset \ ht.toFinset := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a : α
hs✝ : Set.Finite s
ht✝ : Set.Finite t
inst✝ : DecidableEq α
hs : Set.Finite s
ht : Set.Finite t
h : Set.Finite (s \ t)
⊢ Finite.toFinset h = Finite.toFinset hs \ Finite.toFinset ht

Next tactic:
ext
protected theorem toFinset_diff [DecidableEq α] (hs : s.Finite) (ht : t.Finite)
    (h : (s \ t).Finite) : h.toFinset = hs.toFinset \ ht.toFinset := by
  ext
  

Proof state:
case a
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a : α
hs✝ : Set.Finite s
ht✝ : Set.Finite t
inst✝ : DecidableEq α
hs : Set.Finite s
ht : Set.Finite t
h : Set.Finite (s \ t)
a✝ : α
⊢ a✝ ∈ Finite.toFinset h ↔ a✝ ∈ Finite.toFinset hs \ Finite.toFinset ht

Next tactic:
simp
protected theorem toFinset_symmDiff [DecidableEq α] (hs : s.Finite) (ht : t.Finite)
    (h : (s ∆ t).Finite) : h.toFinset = hs.toFinset ∆ ht.toFinset := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a : α
hs✝ : Set.Finite s
ht✝ : Set.Finite t
inst✝ : DecidableEq α
hs : Set.Finite s
ht : Set.Finite t
h : Set.Finite (s ∆ t)
⊢ Finite.toFinset h = Finite.toFinset hs ∆ Finite.toFinset ht

Next tactic:
ext
protected theorem toFinset_symmDiff [DecidableEq α] (hs : s.Finite) (ht : t.Finite)
    (h : (s ∆ t).Finite) : h.toFinset = hs.toFinset ∆ ht.toFinset := by
  ext
  

Proof state:
case a
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a : α
hs✝ : Set.Finite s
ht✝ : Set.Finite t
inst✝ : DecidableEq α
hs : Set.Finite s
ht : Set.Finite t
h : Set.Finite (s ∆ t)
a✝ : α
⊢ a✝ ∈ Finite.toFinset h ↔ a✝ ∈ Finite.toFinset hs ∆ Finite.toFinset ht

Next tactic:
simp [mem_symmDiff, Finset.mem_symmDiff]
protected theorem toFinset_compl [DecidableEq α] [Fintype α] (hs : s.Finite) (h : sᶜ.Finite) :
    h.toFinset = hs.toFinsetᶜ := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a : α
hs✝ : Set.Finite s
ht : Set.Finite t
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hs : Set.Finite s
h : Set.Finite sᶜ
⊢ Finite.toFinset h = (Finite.toFinset hs)ᶜ

Next tactic:
ext
protected theorem toFinset_compl [DecidableEq α] [Fintype α] (hs : s.Finite) (h : sᶜ.Finite) :
    h.toFinset = hs.toFinsetᶜ := by
  ext
  

Proof state:
case a
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a : α
hs✝ : Set.Finite s
ht : Set.Finite t
inst✝¹ : DecidableEq α
inst✝ : Fintype α
hs : Set.Finite s
h : Set.Finite sᶜ
a✝ : α
⊢ a✝ ∈ Finite.toFinset h ↔ a✝ ∈ (Finite.toFinset hs)ᶜ

Next tactic:
simp
protected theorem toFinset_univ [Fintype α] (h : (Set.univ : Set α).Finite) :
    h.toFinset = Finset.univ := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a : α
hs : Set.Finite s
ht : Set.Finite t
inst✝ : Fintype α
h : Set.Finite univ
⊢ Finite.toFinset h = Finset.univ

Next tactic:
simp
protected theorem toFinset_empty (h : (∅ : Set α).Finite) : h.toFinset = ∅ := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a : α
hs : Set.Finite s
ht : Set.Finite t
h : Set.Finite ∅
⊢ Finite.toFinset h = ∅

Next tactic:
simp
protected theorem toFinset_image [DecidableEq β] (f : α → β) (hs : s.Finite) (h : (f '' s).Finite) :
    h.toFinset = hs.toFinset.image f := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a : α
hs✝ : Set.Finite s
ht : Set.Finite t
inst✝ : DecidableEq β
f : α → β
hs : Set.Finite s
h : Set.Finite (f '' s)
⊢ Finite.toFinset h = Finset.image f (Finite.toFinset hs)

Next tactic:
ext
protected theorem toFinset_image [DecidableEq β] (f : α → β) (hs : s.Finite) (h : (f '' s).Finite) :
    h.toFinset = hs.toFinset.image f := by
  ext
  

Proof state:
case a
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a : α
hs✝ : Set.Finite s
ht : Set.Finite t
inst✝ : DecidableEq β
f : α → β
hs : Set.Finite s
h : Set.Finite (f '' s)
a✝ : β
⊢ a✝ ∈ Finite.toFinset h ↔ a✝ ∈ Finset.image f (Finite.toFinset hs)

Next tactic:
simp
protected theorem toFinset_range [DecidableEq α] [Fintype β] (f : β → α) (h : (range f).Finite) :
    h.toFinset = Finset.univ.image f := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a : α
hs : Set.Finite s
ht : Set.Finite t
inst✝¹ : DecidableEq α
inst✝ : Fintype β
f : β → α
h : Set.Finite (range f)
⊢ Finite.toFinset h = Finset.image f Finset.univ

Next tactic:
ext
protected theorem toFinset_range [DecidableEq α] [Fintype β] (f : β → α) (h : (range f).Finite) :
    h.toFinset = Finset.univ.image f := by
  ext
  

Proof state:
case a
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
a : α
hs : Set.Finite s
ht : Set.Finite t
inst✝¹ : DecidableEq α
inst✝ : Fintype β
f : β → α
h : Set.Finite (range f)
a✝ : α
⊢ a✝ ∈ Finite.toFinset h ↔ a✝ ∈ Finset.image f Finset.univ

Next tactic:
simp
instance fintypeUnion [DecidableEq α] (s t : Set α) [Fintype s] [Fintype t] :
    Fintype (s ∪ t : Set α) :=
  Fintype.ofFinset (s.toFinset ∪ t.toFinset) <| by 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
inst✝² : DecidableEq α
s t : Set α
inst✝¹ : Fintype ↑s
inst✝ : Fintype ↑t
⊢ ∀ (x : α), x ∈ toFinset s ∪ toFinset t ↔ x ∈ s ∪ t

Next tactic:
simp
instance fintypeSep (s : Set α) (p : α → Prop) [Fintype s] [DecidablePred p] :
    Fintype ({ a ∈ s | p a } : Set α) :=
  Fintype.ofFinset (s.toFinset.filter p) <| by 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
p : α → Prop
inst✝¹ : Fintype ↑s
inst✝ : DecidablePred p
⊢ ∀ (x : α), x ∈ Finset.filter p (toFinset s) ↔ x ∈ {a | a ∈ s ∧ p a}

Next tactic:
simp
instance fintypeInter (s t : Set α) [DecidableEq α] [Fintype s] [Fintype t] :
    Fintype (s ∩ t : Set α) :=
  Fintype.ofFinset (s.toFinset ∩ t.toFinset) <| by 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
inst✝² : DecidableEq α
inst✝¹ : Fintype ↑s
inst✝ : Fintype ↑t
⊢ ∀ (x : α), x ∈ toFinset s ∩ toFinset t ↔ x ∈ s ∩ t

Next tactic:
simp
/-- A `Fintype` instance for set intersection where the left set has a `Fintype` instance. -/
instance fintypeInterOfLeft (s t : Set α) [Fintype s] [DecidablePred (· ∈ t)] :
    Fintype (s ∩ t : Set α) :=
  Fintype.ofFinset (s.toFinset.filter (· ∈ t)) <| by 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
inst✝¹ : Fintype ↑s
inst✝ : DecidablePred fun x => x ∈ t
⊢ ∀ (x : α), x ∈ Finset.filter (fun x => x ∈ t) (toFinset s) ↔ x ∈ s ∩ t

Next tactic:
simp
/-- A `Fintype` instance for set intersection where the right set has a `Fintype` instance. -/
instance fintypeInterOfRight (s t : Set α) [Fintype t] [DecidablePred (· ∈ s)] :
    Fintype (s ∩ t : Set α) :=
  Fintype.ofFinset (t.toFinset.filter (· ∈ s)) <| by 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
inst✝¹ : Fintype ↑t
inst✝ : DecidablePred fun x => x ∈ s
⊢ ∀ (x : α), x ∈ Finset.filter (fun x => x ∈ s) (toFinset t) ↔ x ∈ s ∩ t

Next tactic:
simp [and_comm]
/-- A `Fintype` structure on a set defines a `Fintype` structure on its subset. -/
def fintypeSubset (s : Set α) {t : Set α} [Fintype s] [DecidablePred (· ∈ t)] (h : t ⊆ s) :
    Fintype t := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
inst✝¹ : Fintype ↑s
inst✝ : DecidablePred fun x => x ∈ t
h : t ⊆ s
⊢ Fintype ↑t

Next tactic:
rw [← inter_eq_self_of_subset_right h]
/-- A `Fintype` structure on a set defines a `Fintype` structure on its subset. -/
def fintypeSubset (s : Set α) {t : Set α} [Fintype s] [DecidablePred (· ∈ t)] (h : t ⊆ s) :
    Fintype t := by
  rw [← inter_eq_self_of_subset_right h]
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s t : Set α
inst✝¹ : Fintype ↑s
inst✝ : DecidablePred fun x => x ∈ t
h : t ⊆ s
⊢ Fintype ↑(s ∩ t)

Next tactic:
apply Set.fintypeInterOfLeft
instance fintypeDiff [DecidableEq α] (s t : Set α) [Fintype s] [Fintype t] :
    Fintype (s \ t : Set α) :=
  Fintype.ofFinset (s.toFinset \ t.toFinset) <| by 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
inst✝² : DecidableEq α
s t : Set α
inst✝¹ : Fintype ↑s
inst✝ : Fintype ↑t
⊢ ∀ (x : α), x ∈ toFinset s \ toFinset t ↔ x ∈ s \ t

Next tactic:
simp
instance fintypeiUnion [DecidableEq α] [Fintype (PLift ι)] (f : ι → Set α) [∀ i, Fintype (f i)] :
    Fintype (⋃ i, f i) :=
  Fintype.ofFinset (Finset.univ.biUnion fun i : PLift ι => (f i.down).toFinset) <| by 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
inst✝² : DecidableEq α
inst✝¹ : Fintype (PLift ι)
f : ι → Set α
inst✝ : (i : ι) → Fintype ↑(f i)
⊢ ∀ (x : α), (x ∈ Finset.biUnion Finset.univ fun i => toFinset (f i.down)) ↔ x ∈ ⋃ i, f i

Next tactic:
simp
instance fintypesUnion [DecidableEq α] {s : Set (Set α)} [Fintype s]
    [H : ∀ t : s, Fintype (t : Set α)] : Fintype (⋃₀ s) := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
inst✝¹ : DecidableEq α
s : Set (Set α)
inst✝ : Fintype ↑s
H : (t : ↑s) → Fintype ↑↑t
⊢ Fintype ↑(⋃₀ s)

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

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

Next tactic:
exact @Set.fintypeiUnion _ _ _ _ _ H
/-- A union of sets with `Fintype` structure over a set with `Fintype` structure has a `Fintype`
structure. -/
def fintypeBiUnion [DecidableEq α] {ι : Type*} (s : Set ι) [Fintype s] (t : ι → Set α)
    (H : ∀ i ∈ s, Fintype (t i)) : Fintype (⋃ x ∈ s, t x) :=
  haveI : ∀ i : toFinset s, Fintype (t i) := fun i => H i (mem_toFinset.1 i.2)
  Fintype.ofFinset (s.toFinset.attach.biUnion fun x => (t x).toFinset) fun x => by 

Proof state:
α : Type u
β : Type v
ι✝ : Sort w
γ : Type x
inst✝¹ : DecidableEq α
ι : Type u_1
s : Set ι
inst✝ : Fintype ↑s
t : ι → Set α
H : (i : ι) → i ∈ s → Fintype ↑(t i)
this : (i : { x // x ∈ toFinset s }) → Fintype ↑(t ↑i)
x : α
⊢ (x ∈ Finset.biUnion (Finset.attach (toFinset s)) fun x => toFinset (t ↑x)) ↔ x ∈ ⋃ x ∈ s, t x

Next tactic:
simp
instance fintypeBiUnion' [DecidableEq α] {ι : Type*} (s : Set ι) [Fintype s] (t : ι → Set α)
    [∀ i, Fintype (t i)] : Fintype (⋃ x ∈ s, t x) :=
  Fintype.ofFinset (s.toFinset.biUnion fun x => (t x).toFinset) <| by 

Proof state:
α : Type u
β : Type v
ι✝ : Sort w
γ : Type x
inst✝² : DecidableEq α
ι : Type u_1
s : Set ι
inst✝¹ : Fintype ↑s
t : ι → Set α
inst✝ : (i : ι) → Fintype ↑(t i)
⊢ ∀ (x : α), (x ∈ Finset.biUnion (toFinset s) fun x => toFinset (t x)) ↔ x ∈ ⋃ x ∈ s, t x

Next tactic:
simp
instance fintypeEmpty : Fintype (∅ : Set α) :=
  Fintype.ofFinset ∅ <| by 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
⊢ ∀ (x : α), x ∈ ∅ ↔ x ∈ ∅

Next tactic:
simp
instance fintypeSingleton (a : α) : Fintype ({a} : Set α) :=
  Fintype.ofFinset {a} <| by 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
a : α
⊢ ∀ (x : α), x ∈ {a} ↔ x ∈ {a}

Next tactic:
simp
/-- A `Fintype` instance for inserting an element into a `Set` using the
corresponding `insert` function on `Finset`. This requires `DecidableEq α`.
There is also `Set.fintypeInsert'` when `a ∈ s` is decidable. -/
instance fintypeInsert (a : α) (s : Set α) [DecidableEq α] [Fintype s] :
    Fintype (insert a s : Set α) :=
  Fintype.ofFinset (insert a s.toFinset) <| by 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
a : α
s : Set α
inst✝¹ : DecidableEq α
inst✝ : Fintype ↑s
⊢ ∀ (x : α), x ∈ insert a (toFinset s) ↔ x ∈ insert a s

Next tactic:
simp
/-- A `Fintype` structure on `insert a s` when inserting a new element. -/
def fintypeInsertOfNotMem {a : α} (s : Set α) [Fintype s] (h : a ∉ s) :
    Fintype (insert a s : Set α) :=
  Fintype.ofFinset ⟨a ::ₘ s.toFinset.1, s.toFinset.nodup.cons (by 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
a : α
s : Set α
inst✝ : Fintype ↑s
h : a ∉ s
⊢ a ∉ (toFinset s).val

Next tactic:
simp [h]
/-- A `Fintype` structure on `insert a s` when inserting a new element. -/
def fintypeInsertOfNotMem {a : α} (s : Set α) [Fintype s] (h : a ∉ s) :
    Fintype (insert a s : Set α) :=
  Fintype.ofFinset ⟨a ::ₘ s.toFinset.1, s.toFinset.nodup.cons (by simp [h])⟩ <| by 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
a : α
s : Set α
inst✝ : Fintype ↑s
h : a ∉ s
⊢ ∀ (x : α),
    x ∈ { val := a ::ₘ (toFinset s).val, nodup := (_ : Multiset.Nodup (a ::ₘ (toFinset s).val)) } ↔ x ∈ insert a s

Next tactic:
simp
/-- A `Fintype` structure on `insert a s` when inserting a pre-existing element. -/
def fintypeInsertOfMem {a : α} (s : Set α) [Fintype s] (h : a ∈ s) : Fintype (insert a s : Set α) :=
  Fintype.ofFinset s.toFinset <| by 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
a : α
s : Set α
inst✝ : Fintype ↑s
h : a ∈ s
⊢ ∀ (x : α), x ∈ toFinset s ↔ x ∈ insert a s

Next tactic:
simp [h]
instance fintypeImage [DecidableEq β] (s : Set α) (f : α → β) [Fintype s] : Fintype (f '' s) :=
  Fintype.ofFinset (s.toFinset.image f) <| by 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
inst✝¹ : DecidableEq β
s : Set α
f : α → β
inst✝ : Fintype ↑s
⊢ ∀ (x : β), x ∈ Finset.image f (toFinset s) ↔ x ∈ f '' s

Next tactic:
simp
/-- If a function `f` has a partial inverse and sends a set `s` to a set with `[Fintype]` instance,
then `s` has a `Fintype` structure as well. -/
def fintypeOfFintypeImage (s : Set α) {f : α → β} {g} (I : IsPartialInv f g) [Fintype (f '' s)] :
    Fintype s :=
  Fintype.ofFinset ⟨_, (f '' s).toFinset.2.filterMap g <| injective_of_isPartialInv_right I⟩
    fun a => by
    

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
f : α → β
g : β → Option α
I : IsPartialInv f g
inst✝ : Fintype ↑(f '' s)
a : α
⊢ a ∈
      { val := Multiset.filterMap g (toFinset (f '' s)).val,
        nodup := (_ : Multiset.Nodup (Multiset.filterMap g (toFinset (f '' s)).val)) } ↔
    a ∈ s

Next tactic:
suffices (∃ b x, f x = b ∧ g b = some a ∧ x ∈ s) ↔ a ∈ s by
      simpa [exists_and_left.symm, and_comm, and_left_comm, and_assoc]
/-- If a function `f` has a partial inverse and sends a set `s` to a set with `[Fintype]` instance,
then `s` has a `Fintype` structure as well. -/
def fintypeOfFintypeImage (s : Set α) {f : α → β} {g} (I : IsPartialInv f g) [Fintype (f '' s)] :
    Fintype s :=
  Fintype.ofFinset ⟨_, (f '' s).toFinset.2.filterMap g <| injective_of_isPartialInv_right I⟩
    fun a => by
    suffices (∃ b x, f x = b ∧ g b = some a ∧ x ∈ s) ↔ a ∈ s by
      

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
f : α → β
g : β → Option α
I : IsPartialInv f g
inst✝ : Fintype ↑(f '' s)
a : α
this : (∃ b x, f x = b ∧ g b = some a ∧ x ∈ s) ↔ a ∈ s
⊢ a ∈
      { val := Multiset.filterMap g (toFinset (f '' s)).val,
        nodup := (_ : Multiset.Nodup (Multiset.filterMap g (toFinset (f '' s)).val)) } ↔
    a ∈ s

Next tactic:
simpa [exists_and_left.symm, and_comm, and_left_comm, and_assoc]
/-- If a function `f` has a partial inverse and sends a set `s` to a set with `[Fintype]` instance,
then `s` has a `Fintype` structure as well. -/
def fintypeOfFintypeImage (s : Set α) {f : α → β} {g} (I : IsPartialInv f g) [Fintype (f '' s)] :
    Fintype s :=
  Fintype.ofFinset ⟨_, (f '' s).toFinset.2.filterMap g <| injective_of_isPartialInv_right I⟩
    fun a => by
    suffices (∃ b x, f x = b ∧ g b = some a ∧ x ∈ s) ↔ a ∈ s by
      simpa [exists_and_left.symm, and_comm, and_left_comm, and_assoc]
    

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
f : α → β
g : β → Option α
I : IsPartialInv f g
inst✝ : Fintype ↑(f '' s)
a : α
⊢ (∃ b x, f x = b ∧ g b = some a ∧ x ∈ s) ↔ a ∈ s

Next tactic:
rw [exists_swap]
/-- If a function `f` has a partial inverse and sends a set `s` to a set with `[Fintype]` instance,
then `s` has a `Fintype` structure as well. -/
def fintypeOfFintypeImage (s : Set α) {f : α → β} {g} (I : IsPartialInv f g) [Fintype (f '' s)] :
    Fintype s :=
  Fintype.ofFinset ⟨_, (f '' s).toFinset.2.filterMap g <| injective_of_isPartialInv_right I⟩
    fun a => by
    suffices (∃ b x, f x = b ∧ g b = some a ∧ x ∈ s) ↔ a ∈ s by
      simpa [exists_and_left.symm, and_comm, and_left_comm, and_assoc]
    rw [exists_swap]
    

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
f : α → β
g : β → Option α
I : IsPartialInv f g
inst✝ : Fintype ↑(f '' s)
a : α
⊢ (∃ y x, f y = x ∧ g x = some a ∧ y ∈ s) ↔ a ∈ s

Next tactic:
suffices (∃ x, x ∈ s ∧ g (f x) = some a) ↔ a ∈ s by simpa [and_comm, and_left_comm, and_assoc]
/-- If a function `f` has a partial inverse and sends a set `s` to a set with `[Fintype]` instance,
then `s` has a `Fintype` structure as well. -/
def fintypeOfFintypeImage (s : Set α) {f : α → β} {g} (I : IsPartialInv f g) [Fintype (f '' s)] :
    Fintype s :=
  Fintype.ofFinset ⟨_, (f '' s).toFinset.2.filterMap g <| injective_of_isPartialInv_right I⟩
    fun a => by
    suffices (∃ b x, f x = b ∧ g b = some a ∧ x ∈ s) ↔ a ∈ s by
      simpa [exists_and_left.symm, and_comm, and_left_comm, and_assoc]
    rw [exists_swap]
    suffices (∃ x, x ∈ s ∧ g (f x) = some a) ↔ a ∈ s by 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
f : α → β
g : β → Option α
I : IsPartialInv f g
inst✝ : Fintype ↑(f '' s)
a : α
this : (∃ x ∈ s, g (f x) = some a) ↔ a ∈ s
⊢ (∃ y x, f y = x ∧ g x = some a ∧ y ∈ s) ↔ a ∈ s

Next tactic:
simpa [and_comm, and_left_comm, and_assoc]
/-- If a function `f` has a partial inverse and sends a set `s` to a set with `[Fintype]` instance,
then `s` has a `Fintype` structure as well. -/
def fintypeOfFintypeImage (s : Set α) {f : α → β} {g} (I : IsPartialInv f g) [Fintype (f '' s)] :
    Fintype s :=
  Fintype.ofFinset ⟨_, (f '' s).toFinset.2.filterMap g <| injective_of_isPartialInv_right I⟩
    fun a => by
    suffices (∃ b x, f x = b ∧ g b = some a ∧ x ∈ s) ↔ a ∈ s by
      simpa [exists_and_left.symm, and_comm, and_left_comm, and_assoc]
    rw [exists_swap]
    suffices (∃ x, x ∈ s ∧ g (f x) = some a) ↔ a ∈ s by simpa [and_comm, and_left_comm, and_assoc]
    

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
f : α → β
g : β → Option α
I : IsPartialInv f g
inst✝ : Fintype ↑(f '' s)
a : α
⊢ (∃ x ∈ s, g (f x) = some a) ↔ a ∈ s

Next tactic:
simp [I _, (injective_of_isPartialInv I).eq_iff]
instance fintypeRange [DecidableEq α] (f : ι → α) [Fintype (PLift ι)] : Fintype (range f) :=
  Fintype.ofFinset (Finset.univ.image <| f ∘ PLift.down) <| by 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
inst✝¹ : DecidableEq α
f : ι → α
inst✝ : Fintype (PLift ι)
⊢ ∀ (x : α), x ∈ Finset.image (f ∘ PLift.down) Finset.univ ↔ x ∈ range f

Next tactic:
simp [Equiv.plift.exists_congr_left]
instance fintypeLTNat (n : ℕ) : Fintype { i | i < n } :=
  Fintype.ofFinset (Finset.range n) <| by 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
n : ℕ
⊢ ∀ (x : ℕ), x ∈ Finset.range n ↔ x ∈ {i | i < n}

Next tactic:
simp
instance fintypeLENat (n : ℕ) : Fintype { i | i ≤ n } := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
n : ℕ
⊢ Fintype ↑{i | i ≤ n}

Next tactic:
simpa [Nat.lt_succ_iff] using Set.fintypeLTNat (n + 1)
instance fintypeProd (s : Set α) (t : Set β) [Fintype s] [Fintype t] :
    Fintype (s ×ˢ t : Set (α × β)) :=
  Fintype.ofFinset (s.toFinset ×ˢ t.toFinset) <| by 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
s : Set α
t : Set β
inst✝¹ : Fintype ↑s
inst✝ : Fintype ↑t
⊢ ∀ (x : α × β), x ∈ toFinset s ×ˢ toFinset t ↔ x ∈ s ×ˢ t

Next tactic:
simp
instance fintypeOffDiag [DecidableEq α] (s : Set α) [Fintype s] : Fintype s.offDiag :=
  Fintype.ofFinset s.toFinset.offDiag <| by 

Proof state:
α : Type u
β : Type v
ι : Sort w
γ : Type x
inst✝¹ : DecidableEq α
s : Set α
inst✝ : Fintype ↑s
⊢ ∀ (x : α × α), x ∈ Finset.offDiag (toFinset s) ↔ x ∈ offDiag s

Next tactic:
simp