l3lab/ntp-mathlib huggingface dataset:
theorem erase_image_subset_image_erase [DecidableEq α] (f : α → β) (s : Finset α) (a : α) :
    (s.image f).erase (f a) ⊆ (s.erase a).image f := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s✝ : Finset α
t : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq α
f : α → β
s : Finset α
a : α
⊢ erase (image f s) (f a) ⊆ image f (erase s a)

Next tactic:
simp only [subset_iff, and_imp, exists_prop, mem_image, exists_imp, mem_erase]
theorem erase_image_subset_image_erase [DecidableEq α] (f : α → β) (s : Finset α) (a : α) :
    (s.image f).erase (f a) ⊆ (s.erase a).image f := by
  simp only [subset_iff, and_imp, exists_prop, mem_image, exists_imp, mem_erase]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s✝ : Finset α
t : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq α
f : α → β
s : Finset α
a : α
⊢ ∀ ⦃x : β⦄, x ≠ f a → ∀ x_1 ∈ s, f x_1 = x → ∃ a_4, (a_4 ≠ a ∧ a_4 ∈ s) ∧ f a_4 = x

Next tactic:
rintro b hb x hx rfl
theorem erase_image_subset_image_erase [DecidableEq α] (f : α → β) (s : Finset α) (a : α) :
    (s.image f).erase (f a) ⊆ (s.erase a).image f := by
  simp only [subset_iff, and_imp, exists_prop, mem_image, exists_imp, mem_erase]
  rintro b hb x hx rfl
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s✝ : Finset α
t : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq α
f : α → β
s : Finset α
a x : α
hx : x ∈ s
hb : f x ≠ f a
⊢ ∃ a_1, (a_1 ≠ a ∧ a_1 ∈ s) ∧ f a_1 = f x

Next tactic:
exact ⟨_, ⟨ne_of_apply_ne f hb, hx⟩, rfl⟩
@[simp]
theorem image_erase [DecidableEq α] {f : α → β} (hf : Injective f) (s : Finset α) (a : α) :
    (s.erase a).image f = (s.image f).erase (f a) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s✝ : Finset α
t : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq α
f : α → β
hf : Injective f
s : Finset α
a : α
⊢ image f (erase s a) = erase (image f s) (f a)

Next tactic:
refine' (erase_image_subset_image_erase _ _ _).antisymm' fun b => _
@[simp]
theorem image_erase [DecidableEq α] {f : α → β} (hf : Injective f) (s : Finset α) (a : α) :
    (s.erase a).image f = (s.image f).erase (f a) := by
  refine' (erase_image_subset_image_erase _ _ _).antisymm' fun b => _
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s✝ : Finset α
t : Finset β
a✝ : α
b✝ c : β
inst✝ : DecidableEq α
f : α → β
hf : Injective f
s : Finset α
a : α
b : β
⊢ b ∈ image f (erase s a) → b ∈ erase (image f s) (f a)

Next tactic:
simp only [mem_image, exists_prop, mem_erase]
@[simp]
theorem image_erase [DecidableEq α] {f : α → β} (hf : Injective f) (s : Finset α) (a : α) :
    (s.erase a).image f = (s.image f).erase (f a) := by
  refine' (erase_image_subset_image_erase _ _ _).antisymm' fun b => _
  simp only [mem_image, exists_prop, mem_erase]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s✝ : Finset α
t : Finset β
a✝ : α
b✝ c : β
inst✝ : DecidableEq α
f : α → β
hf : Injective f
s : Finset α
a : α
b : β
⊢ (∃ a_1, (a_1 ≠ a ∧ a_1 ∈ s) ∧ f a_1 = b) → b ≠ f a ∧ ∃ a ∈ s, f a = b

Next tactic:
rintro ⟨a', ⟨haa', ha'⟩, rfl⟩
@[simp]
theorem image_erase [DecidableEq α] {f : α → β} (hf : Injective f) (s : Finset α) (a : α) :
    (s.erase a).image f = (s.image f).erase (f a) := by
  refine' (erase_image_subset_image_erase _ _ _).antisymm' fun b => _
  simp only [mem_image, exists_prop, mem_erase]
  rintro ⟨a', ⟨haa', ha'⟩, rfl⟩
  

Proof state:
case intro.intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s✝ : Finset α
t : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq α
f : α → β
hf : Injective f
s : Finset α
a a' : α
haa' : a' ≠ a
ha' : a' ∈ s
⊢ f a' ≠ f a ∧ ∃ a ∈ s, f a = f a'

Next tactic:
exact ⟨hf.ne haa', a', ha', rfl⟩
theorem image_sdiff [DecidableEq α] {f : α → β} (s t : Finset α) (hf : Injective f) :
    (s \ t).image f = s.image f \ t.image f :=
  coe_injective <| by
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s✝ : Finset α
t✝ : Finset β
a : α
b c : β
inst✝ : DecidableEq α
f : α → β
s t : Finset α
hf : Injective f
⊢ ↑(image f (s \ t)) = ↑(image f s \ image f t)

Next tactic:
push_cast
theorem image_sdiff [DecidableEq α] {f : α → β} (s t : Finset α) (hf : Injective f) :
    (s \ t).image f = s.image f \ t.image f :=
  coe_injective <| by
    push_cast
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s✝ : Finset α
t✝ : Finset β
a : α
b c : β
inst✝ : DecidableEq α
f : α → β
s t : Finset α
hf : Injective f
⊢ f '' (↑s \ ↑t) = f '' ↑s \ f '' ↑t

Next tactic:
exact Set.image_diff hf _ _
theorem image_symmDiff [DecidableEq α] {f : α → β} (s t : Finset α) (hf : Injective f) :
    (s ∆ t).image f = s.image f ∆ t.image f :=
  coe_injective <| by
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s✝ : Finset α
t✝ : Finset β
a : α
b c : β
inst✝ : DecidableEq α
f : α → β
s t : Finset α
hf : Injective f
⊢ ↑(image f (s ∆ t)) = ↑(image f s ∆ image f t)

Next tactic:
push_cast
theorem image_symmDiff [DecidableEq α] {f : α → β} (s t : Finset α) (hf : Injective f) :
    (s ∆ t).image f = s.image f ∆ t.image f :=
  coe_injective <| by
    push_cast
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s✝ : Finset α
t✝ : Finset β
a : α
b c : β
inst✝ : DecidableEq α
f : α → β
s t : Finset α
hf : Injective f
⊢ f '' ↑s ∆ ↑t = (f '' ↑s) ∆ (f '' ↑t)

Next tactic:
exact Set.image_symmDiff hf _ _
theorem mem_range_iff_mem_finset_range_of_mod_eq' [DecidableEq α] {f : ℕ → α} {a : α} {n : ℕ}
    (hn : 0 < n) (h : ∀ i, f (i % n) = f i) :
    a ∈ Set.range f ↔ a ∈ (Finset.range n).image fun i => f i := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s : Finset α
t : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq α
f : ℕ → α
a : α
n : ℕ
hn : 0 < n
h : ∀ (i : ℕ), f (i % n) = f i
⊢ a ∈ Set.range f ↔ a ∈ image (fun i => f i) (range n)

Next tactic:
constructor
theorem mem_range_iff_mem_finset_range_of_mod_eq' [DecidableEq α] {f : ℕ → α} {a : α} {n : ℕ}
    (hn : 0 < n) (h : ∀ i, f (i % n) = f i) :
    a ∈ Set.range f ↔ a ∈ (Finset.range n).image fun i => f i := by
  constructor
  · 

Proof state:
case mp
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s : Finset α
t : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq α
f : ℕ → α
a : α
n : ℕ
hn : 0 < n
h : ∀ (i : ℕ), f (i % n) = f i
⊢ a ∈ Set.range f → a ∈ image (fun i => f i) (range n)

Next tactic:
rintro ⟨i, hi⟩
theorem mem_range_iff_mem_finset_range_of_mod_eq' [DecidableEq α] {f : ℕ → α} {a : α} {n : ℕ}
    (hn : 0 < n) (h : ∀ i, f (i % n) = f i) :
    a ∈ Set.range f ↔ a ∈ (Finset.range n).image fun i => f i := by
  constructor
  · rintro ⟨i, hi⟩
    

Proof state:
case mp.intro
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s : Finset α
t : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq α
f : ℕ → α
a : α
n : ℕ
hn : 0 < n
h : ∀ (i : ℕ), f (i % n) = f i
i : ℕ
hi : f i = a
⊢ a ∈ image (fun i => f i) (range n)

Next tactic:
simp only [mem_image, exists_prop, mem_range]
theorem mem_range_iff_mem_finset_range_of_mod_eq' [DecidableEq α] {f : ℕ → α} {a : α} {n : ℕ}
    (hn : 0 < n) (h : ∀ i, f (i % n) = f i) :
    a ∈ Set.range f ↔ a ∈ (Finset.range n).image fun i => f i := by
  constructor
  · rintro ⟨i, hi⟩
    simp only [mem_image, exists_prop, mem_range]
    

Proof state:
case mp.intro
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s : Finset α
t : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq α
f : ℕ → α
a : α
n : ℕ
hn : 0 < n
h : ∀ (i : ℕ), f (i % n) = f i
i : ℕ
hi : f i = a
⊢ ∃ a_1 < n, f a_1 = a

Next tactic:
exact ⟨i % n, Nat.mod_lt i hn, (rfl.congr hi).mp (h i)⟩
theorem mem_range_iff_mem_finset_range_of_mod_eq' [DecidableEq α] {f : ℕ → α} {a : α} {n : ℕ}
    (hn : 0 < n) (h : ∀ i, f (i % n) = f i) :
    a ∈ Set.range f ↔ a ∈ (Finset.range n).image fun i => f i := by
  constructor
  · rintro ⟨i, hi⟩
    simp only [mem_image, exists_prop, mem_range]
    exact ⟨i % n, Nat.mod_lt i hn, (rfl.congr hi).mp (h i)⟩
  · 

Proof state:
case mpr
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s : Finset α
t : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq α
f : ℕ → α
a : α
n : ℕ
hn : 0 < n
h : ∀ (i : ℕ), f (i % n) = f i
⊢ a ∈ image (fun i => f i) (range n) → a ∈ Set.range f

Next tactic:
rintro h
theorem mem_range_iff_mem_finset_range_of_mod_eq' [DecidableEq α] {f : ℕ → α} {a : α} {n : ℕ}
    (hn : 0 < n) (h : ∀ i, f (i % n) = f i) :
    a ∈ Set.range f ↔ a ∈ (Finset.range n).image fun i => f i := by
  constructor
  · rintro ⟨i, hi⟩
    simp only [mem_image, exists_prop, mem_range]
    exact ⟨i % n, Nat.mod_lt i hn, (rfl.congr hi).mp (h i)⟩
  · rintro h
    

Proof state:
case mpr
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s : Finset α
t : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq α
f : ℕ → α
a : α
n : ℕ
hn : 0 < n
h✝ : ∀ (i : ℕ), f (i % n) = f i
h : a ∈ image (fun i => f i) (range n)
⊢ a ∈ Set.range f

Next tactic:
simp only [mem_image, exists_prop, Set.mem_range, mem_range] at *
theorem mem_range_iff_mem_finset_range_of_mod_eq' [DecidableEq α] {f : ℕ → α} {a : α} {n : ℕ}
    (hn : 0 < n) (h : ∀ i, f (i % n) = f i) :
    a ∈ Set.range f ↔ a ∈ (Finset.range n).image fun i => f i := by
  constructor
  · rintro ⟨i, hi⟩
    simp only [mem_image, exists_prop, mem_range]
    exact ⟨i % n, Nat.mod_lt i hn, (rfl.congr hi).mp (h i)⟩
  · rintro h
    simp only [mem_image, exists_prop, Set.mem_range, mem_range] at *
    

Proof state:
case mpr
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s : Finset α
t : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq α
f : ℕ → α
a : α
n : ℕ
hn : 0 < n
h✝ : ∀ (i : ℕ), f (i % n) = f i
h : ∃ a_1 < n, f a_1 = a
⊢ ∃ y, f y = a

Next tactic:
rcases h with ⟨i, _, ha⟩
theorem mem_range_iff_mem_finset_range_of_mod_eq' [DecidableEq α] {f : ℕ → α} {a : α} {n : ℕ}
    (hn : 0 < n) (h : ∀ i, f (i % n) = f i) :
    a ∈ Set.range f ↔ a ∈ (Finset.range n).image fun i => f i := by
  constructor
  · rintro ⟨i, hi⟩
    simp only [mem_image, exists_prop, mem_range]
    exact ⟨i % n, Nat.mod_lt i hn, (rfl.congr hi).mp (h i)⟩
  · rintro h
    simp only [mem_image, exists_prop, Set.mem_range, mem_range] at *
    rcases h with ⟨i, _, ha⟩
    

Proof state:
case mpr.intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s : Finset α
t : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq α
f : ℕ → α
a : α
n : ℕ
hn : 0 < n
h : ∀ (i : ℕ), f (i % n) = f i
i : ℕ
left✝ : i < n
ha : f i = a
⊢ ∃ y, f y = a

Next tactic:
exact ⟨i, ha⟩
theorem mem_range_iff_mem_finset_range_of_mod_eq [DecidableEq α] {f : ℤ → α} {a : α} {n : ℕ}
    (hn : 0 < n) (h : ∀ i, f (i % n) = f i) :
    a ∈ Set.range f ↔ a ∈ (Finset.range n).image (fun (i : ℕ) => f i) :=
  suffices (∃ i, f (i % n) = a) ↔ ∃ i, i < n ∧ f ↑i = a by simpa [h]
  have hn' : 0 < (n : ℤ) := Int.ofNat_lt.mpr hn
  Iff.intro
    (fun ⟨i, hi⟩ =>
      have : 0 ≤ i % ↑n := Int.emod_nonneg _ (ne_of_gt hn')
      ⟨Int.toNat (i % n), by
        

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s : Finset α
t : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq α
f : ℤ → α
a : α
n : ℕ
hn : 0 < n
h : ∀ (i : ℤ), f (i % ↑n) = f i
hn' : 0 < ↑n
x✝ : ∃ i, f (i % ↑n) = a
i : ℤ
hi : f (i % ↑n) = a
this : 0 ≤ i % ↑n
⊢ Int.toNat (i % ↑n) < n ∧ f ↑(Int.toNat (i % ↑n)) = a

Next tactic:
rw [← Int.ofNat_lt, Int.toNat_of_nonneg this]
theorem mem_range_iff_mem_finset_range_of_mod_eq [DecidableEq α] {f : ℤ → α} {a : α} {n : ℕ}
    (hn : 0 < n) (h : ∀ i, f (i % n) = f i) :
    a ∈ Set.range f ↔ a ∈ (Finset.range n).image (fun (i : ℕ) => f i) :=
  suffices (∃ i, f (i % n) = a) ↔ ∃ i, i < n ∧ f ↑i = a by simpa [h]
  have hn' : 0 < (n : ℤ) := Int.ofNat_lt.mpr hn
  Iff.intro
    (fun ⟨i, hi⟩ =>
      have : 0 ≤ i % ↑n := Int.emod_nonneg _ (ne_of_gt hn')
      ⟨Int.toNat (i % n), by
        rw [← Int.ofNat_lt, Int.toNat_of_nonneg this]; 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s : Finset α
t : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq α
f : ℤ → α
a : α
n : ℕ
hn : 0 < n
h : ∀ (i : ℤ), f (i % ↑n) = f i
hn' : 0 < ↑n
x✝ : ∃ i, f (i % ↑n) = a
i : ℤ
hi : f (i % ↑n) = a
this : 0 ≤ i % ↑n
⊢ i % ↑n < ↑n ∧ f (i % ↑n) = a

Next tactic:
exact ⟨Int.emod_lt_of_pos i hn', hi⟩
theorem mem_range_iff_mem_finset_range_of_mod_eq [DecidableEq α] {f : ℤ → α} {a : α} {n : ℕ}
    (hn : 0 < n) (h : ∀ i, f (i % n) = f i) :
    a ∈ Set.range f ↔ a ∈ (Finset.range n).image (fun (i : ℕ) => f i) :=
  suffices (∃ i, f (i % n) = a) ↔ ∃ i, i < n ∧ f ↑i = a by simpa [h]
  have hn' : 0 < (n : ℤ) := Int.ofNat_lt.mpr hn
  Iff.intro
    (fun ⟨i, hi⟩ =>
      have : 0 ≤ i % ↑n := Int.emod_nonneg _ (ne_of_gt hn')
      ⟨Int.toNat (i % n), by
        rw [← Int.ofNat_lt, Int.toNat_of_nonneg this]; exact ⟨Int.emod_lt_of_pos i hn', hi⟩⟩)
    fun ⟨i, hi, ha⟩ =>
    ⟨i, by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s : Finset α
t : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq α
f : ℤ → α
a : α
n : ℕ
hn : 0 < n
h : ∀ (i : ℤ), f (i % ↑n) = f i
hn' : 0 < ↑n
x✝ : ∃ i < n, f ↑i = a
i : ℕ
hi : i < n
ha : f ↑i = a
⊢ f (↑i % ↑n) = a

Next tactic:
rw [Int.emod_eq_of_lt (Int.ofNat_zero_le _) (Int.ofNat_lt_ofNat_of_lt hi), ha]
theorem mem_range_iff_mem_finset_range_of_mod_eq [DecidableEq α] {f : ℤ → α} {a : α} {n : ℕ}
    (hn : 0 < n) (h : ∀ i, f (i % n) = f i) :
    a ∈ Set.range f ↔ a ∈ (Finset.range n).image (fun (i : ℕ) => f i) :=
  suffices (∃ i, f (i % n) = a) ↔ ∃ i, i < n ∧ f ↑i = a by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s : Finset α
t : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq α
f : ℤ → α
a : α
n : ℕ
hn : 0 < n
h : ∀ (i : ℤ), f (i % ↑n) = f i
this : (∃ i, f (i % ↑n) = a) ↔ ∃ i < n, f ↑i = a
⊢ a ∈ Set.range f ↔ a ∈ image (fun i => f ↑i) (range n)

Next tactic:
simpa [h]
theorem range_add (a b : ℕ) : range (a + b) = range a ∪ (range b).map (addLeftEmbedding a) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq β
f g : α → β
s : Finset α
t : Finset β
a✝ : α
b✝ c : β
a b : ℕ
⊢ range (a + b) = range a ∪ map (addLeftEmbedding a) (range b)

Next tactic:
rw [← val_inj, union_val]
theorem range_add (a b : ℕ) : range (a + b) = range a ∪ (range b).map (addLeftEmbedding a) := by
  rw [← val_inj, union_val]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq β
f g : α → β
s : Finset α
t : Finset β
a✝ : α
b✝ c : β
a b : ℕ
⊢ (range (a + b)).val = (range a).val ∪ (map (addLeftEmbedding a) (range b)).val

Next tactic:
exact Multiset.range_add_eq_union a b
@[simp]
theorem attach_image_val [DecidableEq α] {s : Finset α} : s.attach.image Subtype.val = s :=
  eq_of_veq <| by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f g : α → β
s✝ : Finset α
t : Finset β
a : α
b c : β
inst✝ : DecidableEq α
s : Finset α
⊢ (image Subtype.val (attach s)).val = s.val

Next tactic:
rw [image_val, attach_val, Multiset.attach_map_val, dedup_eq_self]
@[simp]
theorem disjoint_image {s t : Finset α} {f : α → β} (hf : Injective f) :
    Disjoint (s.image f) (t.image f) ↔ Disjoint s t := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq β
f✝ g : α → β
s✝ : Finset α
t✝ : Finset β
a : α
b c : β
s t : Finset α
f : α → β
hf : Injective f
⊢ _root_.Disjoint (image f s) (image f t) ↔ _root_.Disjoint s t

Next tactic:
convert disjoint_map ⟨_, hf⟩ using 1
@[simp]
theorem disjoint_image {s t : Finset α} {f : α → β} (hf : Injective f) :
    Disjoint (s.image f) (t.image f) ↔ Disjoint s t := by
  convert disjoint_map ⟨_, hf⟩ using 1
  

Proof state:
case h.e'_1.a
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq β
f✝ g : α → β
s✝ : Finset α
t✝ : Finset β
a : α
b c : β
s t : Finset α
f : α → β
hf : Injective f
⊢ _root_.Disjoint (image f s) (image f t) ↔
    _root_.Disjoint (map { toFun := f, inj' := hf } s) (map { toFun := f, inj' := hf } t)

Next tactic:
simp [map_eq_image]
theorem image_const {s : Finset α} (h : s.Nonempty) (b : β) : (s.image fun _ => b) = singleton b :=
  ext fun b' => by
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq β
f g : α → β
s✝ : Finset α
t : Finset β
a : α
b✝ c : β
s : Finset α
h : Finset.Nonempty s
b b' : β
⊢ b' ∈ image (fun x => b) s ↔ b' ∈ {b}

Next tactic:
simp only [mem_image, exists_prop, exists_and_right, h.bex, true_and_iff, mem_singleton,
      eq_comm]
@[simp]
theorem map_erase [DecidableEq α] (f : α ↪ β) (s : Finset α) (a : α) :
    (s.erase a).map f = (s.map f).erase (f a) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s✝ : Finset α
t : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq α
f : α ↪ β
s : Finset α
a : α
⊢ map f (erase s a) = erase (map f s) (f a)

Next tactic:
simp_rw [map_eq_image]
@[simp]
theorem map_erase [DecidableEq α] (f : α ↪ β) (s : Finset α) (a : α) :
    (s.erase a).map f = (s.map f).erase (f a) := by
  simp_rw [map_eq_image]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s✝ : Finset α
t : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq α
f : α ↪ β
s : Finset α
a : α
⊢ image (⇑f) (erase s a) = erase (image (⇑f) s) (f a)

Next tactic:
exact s.image_erase f.2 a
theorem image_biUnion [DecidableEq γ] {f : α → β} {s : Finset α} {t : β → Finset γ} :
    (s.image f).biUnion t = s.biUnion fun a => t (f a) :=
  haveI := Classical.decEq α
  Finset.induction_on s rfl fun a s _ ih => by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s✝¹ : Finset α
t✝ : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq γ
f : α → β
s✝ : Finset α
t : β → Finset γ
this : DecidableEq α
a : α
s : Finset α
x✝ : a ∉ s
ih : Finset.biUnion (image f s) t = Finset.biUnion s fun a => t (f a)
⊢ Finset.biUnion (image f (insert a s)) t = Finset.biUnion (insert a s) fun a => t (f a)

Next tactic:
simp only [image_insert, biUnion_insert, ih]
theorem biUnion_image [DecidableEq γ] {s : Finset α} {t : α → Finset β} {f : β → γ} :
    (s.biUnion t).image f = s.biUnion fun a => (t a).image f :=
  haveI := Classical.decEq α
  Finset.induction_on s rfl fun a s _ ih => by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : DecidableEq β
f✝ g : α → β
s✝¹ : Finset α
t✝ : Finset β
a✝ : α
b c : β
inst✝ : DecidableEq γ
s✝ : Finset α
t : α → Finset β
f : β → γ
this : DecidableEq α
a : α
s : Finset α
x✝ : a ∉ s
ih : image f (Finset.biUnion s t) = Finset.biUnion s fun a => image f (t a)
⊢ image f (Finset.biUnion (insert a s) t) = Finset.biUnion (insert a s) fun a => image f (t a)

Next tactic:
simp only [biUnion_insert, image_union, ih]
theorem biUnion_singleton {f : α → β} : (s.biUnion fun a => {f a}) = s.image f :=
  ext fun x => by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq β
f✝ g : α → β
s : Finset α
t : Finset β
a : α
b c : β
f : α → β
x : β
⊢ (x ∈ Finset.biUnion s fun a => {f a}) ↔ x ∈ image f s

Next tactic:
simp only [mem_biUnion, mem_image, mem_singleton, eq_comm]
@[simp, norm_cast]
theorem coe_filterMap : (s.filterMap f f_inj : Set β) = {b | ∃ a ∈ s, f a = some b} :=
  Set.ext (by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
f : α → Option β
s' s t : Finset α
f_inj : ∀ (a a' : α), ∀ b ∈ f a, b ∈ f a' → a = a'
⊢ ∀ (x : β), x ∈ ↑(filterMap f s f_inj) ↔ x ∈ {b | ∃ a ∈ s, f a = some b}

Next tactic:
simp only [mem_coe, mem_filterMap, Option.mem_def, Set.mem_setOf_eq, implies_true]
@[simp]
theorem filterMap_some : s.filterMap some (by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
f : α → Option β
s' s t : Finset α
f_inj : ∀ (a a' : α), ∀ b ∈ f a, b ∈ f a' → a = a'
⊢ ∀ (a a' b : α), b ∈ some a → b ∈ some a' → a = a'

Next tactic:
simp
@[simp]
theorem filterMap_some : s.filterMap some (by simp) = s :=
  ext fun _ => by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
f : α → Option β
s' s t : Finset α
f_inj : ∀ (a a' : α), ∀ b ∈ f a, b ∈ f a' → a = a'
x✝ : α
⊢ x✝ ∈ filterMap some s (_ : ∀ (a a_1 a_2 : α), a_2 ∈ some a → a_2 ∈ some a_1 → a = a_1) ↔ x✝ ∈ s

Next tactic:
simp only [mem_filterMap, Option.some.injEq, exists_eq_right]
theorem filterMap_mono (h : s ⊆ t) :
    filterMap f s f_inj ⊆ filterMap f t f_inj := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
f : α → Option β
s' s t : Finset α
f_inj : ∀ (a a' : α), ∀ b ∈ f a, b ∈ f a' → a = a'
h : s ⊆ t
⊢ filterMap f s f_inj ⊆ filterMap f t f_inj

Next tactic:
rw [← val_le_iff] at h ⊢
theorem filterMap_mono (h : s ⊆ t) :
    filterMap f s f_inj ⊆ filterMap f t f_inj := by
  rw [← val_le_iff] at h ⊢
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
f : α → Option β
s' s t : Finset α
f_inj : ∀ (a a' : α), ∀ b ∈ f a, b ∈ f a' → a = a'
h : s.val ≤ t.val
⊢ (filterMap f s f_inj).val ≤ (filterMap f t f_inj).val

Next tactic:
exact Multiset.filterMap_le_filterMap f h
/-- Given a finset `s` and a predicate `p`, `s.subtype p` is the finset of `Subtype p` whose
elements belong to `s`. -/
protected def subtype {α} (p : α → Prop) [DecidablePred p] (s : Finset α) : Finset (Subtype p) :=
  (s.filter p).attach.map
    ⟨fun x => ⟨x.1, by 

Proof state:
α✝ : Type u_1
β : Type u_2
γ : Type u_3
α : Type ?u.156729
p : α → Prop
inst✝ : DecidablePred p
s : Finset α
x : { x // x ∈ filter p s }
⊢ p ↑x

Next tactic:
simpa using (Finset.mem_filter.1 x.2).2
@[simp]
theorem mem_subtype {p : α → Prop} [DecidablePred p] {s : Finset α} :
    ∀ {a : Subtype p}, a ∈ s.subtype p ↔ (a : α) ∈ s
  | ⟨a, ha⟩ => by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
p : α → Prop
inst✝ : DecidablePred p
s : Finset α
a : α
ha : p a
⊢ { val := a, property := ha } ∈ Finset.subtype p s ↔ ↑{ val := a, property := ha } ∈ s

Next tactic:
simp [Finset.subtype, ha]
theorem subtype_eq_empty {p : α → Prop} [DecidablePred p] {s : Finset α} :
    s.subtype p = ∅ ↔ ∀ x, p x → x ∉ s := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
p : α → Prop
inst✝ : DecidablePred p
s : Finset α
⊢ Finset.subtype p s = ∅ ↔ ∀ (x : α), p x → x ∉ s

Next tactic:
simp [ext_iff, Subtype.forall, Subtype.coe_mk]
/-- `s.subtype p` converts back to `s.filter p` with
`Embedding.subtype`. -/
@[simp]
theorem subtype_map (p : α → Prop) [DecidablePred p] {s : Finset α} :
    (s.subtype p).map (Embedding.subtype _) = s.filter p := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
p : α → Prop
inst✝ : DecidablePred p
s : Finset α
⊢ map (Embedding.subtype p) (Finset.subtype p s) = filter p s

Next tactic:
ext x
/-- `s.subtype p` converts back to `s.filter p` with
`Embedding.subtype`. -/
@[simp]
theorem subtype_map (p : α → Prop) [DecidablePred p] {s : Finset α} :
    (s.subtype p).map (Embedding.subtype _) = s.filter p := by
  ext x
  

Proof state:
case a
α : Type u_1
β : Type u_2
γ : Type u_3
p : α → Prop
inst✝ : DecidablePred p
s : Finset α
x : α
⊢ x ∈ map (Embedding.subtype p) (Finset.subtype p s) ↔ x ∈ filter p s

Next tactic:
simp [@and_comm _ (_ = _), @and_left_comm _ (_ = _), @and_comm (p x) (x ∈ s)]
/-- If all elements of a `Finset` satisfy the predicate `p`,
`s.subtype p` converts back to `s` with `Embedding.subtype`. -/
theorem subtype_map_of_mem {p : α → Prop} [DecidablePred p] {s : Finset α} (h : ∀ x ∈ s, p x) :
    (s.subtype p).map (Embedding.subtype _) = s := ext <| by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
p : α → Prop
inst✝ : DecidablePred p
s : Finset α
h : ∀ x ∈ s, p x
⊢ ∀ (a : α), a ∈ map (Embedding.subtype p) (Finset.subtype p s) ↔ a ∈ s

Next tactic:
simpa [subtype_map] using h
/-- If a `Finset` of a subtype is converted to the main type with
`Embedding.subtype`, all elements of the result have the property of
the subtype. -/
theorem property_of_mem_map_subtype {p : α → Prop} (s : Finset { x // p x }) {a : α}
    (h : a ∈ s.map (Embedding.subtype _)) : p a := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
p : α → Prop
s : Finset { x // p x }
a : α
h : a ∈ map (Embedding.subtype fun x => p x) s
⊢ p a

Next tactic:
rcases mem_map.1 h with ⟨x, _, rfl⟩