Theorem: Finset.powersetLen_map
File: Mathlib/Data/Finset/Powerset.lean

tactic: simp only [card_map, mem_powersetLen, le_eq_subset, gt_iff_lt, mem_map, mapEmbedding_apply]
state_before: α : Type u_2
s✝ t✝ : Finset α
β : Type u_1
f : α ↪ β
n : ℕ
s : Finset α
t : Finset β
⊢ t ∈ powersetLen n (map f s) ↔ t ∈ map (mapEmbedding f).toEmbedding (powersetLen n s)

tactic: constructor
state_before: α : Type u_2
s✝ t✝ : Finset α
β : Type u_1
f : α ↪ β
n : ℕ
s : Finset α
t : Finset β
⊢ t ⊆ map f s ∧ card t = n ↔ ∃ a, (a ⊆ s ∧ card a = n) ∧ ↑(mapEmbedding f).toEmbedding a = t

tactic: . classical
  intro h
  have : map f (filter (fun x => (f x ∈ t)) s) = t := by
    ext x
    simp only [mem_map, mem_filter, decide_eq_true_eq]
    exact ⟨fun ⟨_y, ⟨_hy₁, hy₂⟩, hy₃⟩ => hy₃ ▸ hy₂,
      fun hx => let ⟨y, hy⟩ := mem_map.1 (h.1 hx); ⟨y, ⟨hy.1, hy.2 ▸ hx⟩, hy.2⟩⟩
  refine' ⟨_, _, this⟩
  rw [← card_map f, this, h.2]; simp
state_before: case mp
α : Type u_2
s✝ t✝ : Finset α
β : Type u_1
f : α ↪ β
n : ℕ
s : Finset α
t : Finset β
⊢ t ⊆ map f s ∧ card t = n → ∃ a, (a ⊆ s ∧ card a = n) ∧ ↑(mapEmbedding f).toEmbedding a = t

case mpr
α : Type u_2
s✝ t✝ : Finset α
β : Type u_1
f : α ↪ β
n : ℕ
s : Finset α
t : Finset β
⊢ (∃ a, (a ⊆ s ∧ card a = n) ∧ ↑(mapEmbedding f).toEmbedding a = t) → t ⊆ map f s ∧ card t = n

tactic: . rintro ⟨a, ⟨has, rfl⟩, rfl⟩
  dsimp [RelEmbedding.coe_toEmbedding]
  rw [mapEmbedding_apply]
  simp [has]
state_before: case mpr
α : Type u_2
s✝ t✝ : Finset α
β : Type u_1
f : α ↪ β
n : ℕ
s : Finset α
t : Finset β
⊢ (∃ a, (a ⊆ s ∧ card a = n) ∧ ↑(mapEmbedding f).toEmbedding a = t) → t ⊆ map f s ∧ card t = n

tactic: classical
intro h
have : map f (filter (fun x => (f x ∈ t)) s) = t := by
  ext x
  simp only [mem_map, mem_filter, decide_eq_true_eq]
  exact ⟨fun ⟨_y, ⟨_hy₁, hy₂⟩, hy₃⟩ => hy₃ ▸ hy₂,
    fun hx => let ⟨y, hy⟩ := mem_map.1 (h.1 hx); ⟨y, ⟨hy.1, hy.2 ▸ hx⟩, hy.2⟩⟩
refine' ⟨_, _, this⟩
rw [← card_map f, this, h.2]; simp
state_before: case mp
α : Type u_2
s✝ t✝ : Finset α
β : Type u_1
f : α ↪ β
n : ℕ
s : Finset α
t : Finset β
⊢ t ⊆ map f s ∧ card t = n → ∃ a, (a ⊆ s ∧ card a = n) ∧ ↑(mapEmbedding f).toEmbedding a = t

tactic: intro h
state_before: case mp
α : Type u_2
s✝ t✝ : Finset α
β : Type u_1
f : α ↪ β
n : ℕ
s : Finset α
t : Finset β
⊢ t ⊆ map f s ∧ card t = n → ∃ a, (a ⊆ s ∧ card a = n) ∧ ↑(mapEmbedding f).toEmbedding a = t

tactic: have : map f (filter (fun x => (f x ∈ t)) s) = t := by
  ext x
  simp only [mem_map, mem_filter, decide_eq_true_eq]
  exact ⟨fun ⟨_y, ⟨_hy₁, hy₂⟩, hy₃⟩ => hy₃ ▸ hy₂,
    fun hx => let ⟨y, hy⟩ := mem_map.1 (h.1 hx); ⟨y, ⟨hy.1, hy.2 ▸ hx⟩, hy.2⟩⟩
state_before: case mp
α : Type u_2
s✝ t✝ : Finset α
β : Type u_1
f : α ↪ β
n : ℕ
s : Finset α
t : Finset β
h : t ⊆ map f s ∧ card t = n
⊢ ∃ a, (a ⊆ s ∧ card a = n) ∧ ↑(mapEmbedding f).toEmbedding a = t

tactic: refine' ⟨_, _, this⟩
state_before: case mp
α : Type u_2
s✝ t✝ : Finset α
β : Type u_1
f : α ↪ β
n : ℕ
s : Finset α
t : Finset β
h : t ⊆ map f s ∧ card t = n
this : map f (filter (fun x => ↑f x ∈ t) s) = t
⊢ ∃ a, (a ⊆ s ∧ card a = n) ∧ ↑(mapEmbedding f).toEmbedding a = t

tactic: rw [← card_map f, this, h.2]
state_before: case mp
α : Type u_2
s✝ t✝ : Finset α
β : Type u_1
f : α ↪ β
n : ℕ
s : Finset α
t : Finset β
h : t ⊆ map f s ∧ card t = n
this : map f (filter (fun x => ↑f x ∈ t) s) = t
⊢ filter (fun x => ↑f x ∈ t) s ⊆ s ∧ card (filter (fun x => ↑f x ∈ t) s) = n

tactic: simp
state_before: case mp
α : Type u_2
s✝ t✝ : Finset α
β : Type u_1
f : α ↪ β
n : ℕ
s : Finset α
t : Finset β
h : t ⊆ map f s ∧ card t = n
this : map f (filter (fun x => ↑f x ∈ t) s) = t
⊢ filter (fun x => ↑f x ∈ t) s ⊆ s ∧ n = n

tactic: ext x
state_before: α : Type u_2
s✝ t✝ : Finset α
β : Type u_1
f : α ↪ β
n : ℕ
s : Finset α
t : Finset β
h : t ⊆ map f s ∧ card t = n
⊢ map f (filter (fun x => ↑f x ∈ t) s) = t

tactic: simp only [mem_map, mem_filter, decide_eq_true_eq]
state_before: case a
α : Type u_2
s✝ t✝ : Finset α
β : Type u_1
f : α ↪ β
n : ℕ
s : Finset α
t : Finset β
h : t ⊆ map f s ∧ card t = n
x : β
⊢ x ∈ map f (filter (fun x => ↑f x ∈ t) s) ↔ x ∈ t

tactic: exact ⟨fun ⟨_y, ⟨_hy₁, hy₂⟩, hy₃⟩ => hy₃ ▸ hy₂,
  fun hx => let ⟨y, hy⟩ := mem_map.1 (h.1 hx); ⟨y, ⟨hy.1, hy.2 ▸ hx⟩, hy.2⟩⟩
state_before: case a
α : Type u_2
s✝ t✝ : Finset α
β : Type u_1
f : α ↪ β
n : ℕ
s : Finset α
t : Finset β
h : t ⊆ map f s ∧ card t = n
x : β
⊢ (∃ a, (a ∈ s ∧ ↑f a ∈ t) ∧ ↑f a = x) ↔ x ∈ t

tactic: rintro ⟨a, ⟨has, rfl⟩, rfl⟩
state_before: case mpr
α : Type u_2
s✝ t✝ : Finset α
β : Type u_1
f : α ↪ β
n : ℕ
s : Finset α
t : Finset β
⊢ (∃ a, (a ⊆ s ∧ card a = n) ∧ ↑(mapEmbedding f).toEmbedding a = t) → t ⊆ map f s ∧ card t = n

tactic: dsimp [RelEmbedding.coe_toEmbedding]
state_before: case mpr.intro.intro.intro
α : Type u_2
s✝ t : Finset α
β : Type u_1
f : α ↪ β
s a : Finset α
has : a ⊆ s
⊢ ↑(mapEmbedding f).toEmbedding a ⊆ map f s ∧ card (↑(mapEmbedding f).toEmbedding a) = card a

tactic: rw [mapEmbedding_apply]
state_before: case mpr.intro.intro.intro
α : Type u_2
s✝ t : Finset α
β : Type u_1
f : α ↪ β
s a : Finset α
has : a ⊆ s
⊢ ↑(mapEmbedding f) a ⊆ map f s ∧ card (↑(mapEmbedding f) a) = card a

tactic: simp [has]
state_before: case mpr.intro.intro.intro
α : Type u_2
s✝ t : Finset α
β : Type u_1
f : α ↪ β
s a : Finset α
has : a ⊆ s
⊢ map f a ⊆ map f s ∧ card (map f a) = card a