Theorem: Multiset.count_map_eq_count
File: Mathlib/Data/Multiset/Basic.lean

tactic: suffices (filter (fun a : α => f x = f a) s).count x = card (filter (fun a : α => f x = f a) s) by
  rw [count, countP_map, ← this]
  exact count_filter_of_pos <| rfl
state_before: α : Type u_1
β : Type v
γ : Type u_2
inst✝¹ : DecidableEq α
s✝ : Multiset α
inst✝ : DecidableEq β
f : α → β
s : Multiset α
hf : Set.InjOn f {x | x ∈ s}
x : α
H : x ∈ s
⊢ count (f x) (map f s) = count x s
state_after: α : Type u_1
β : Type v
γ : Type u_2
inst✝¹ : DecidableEq α
s✝ : Multiset α
inst✝ : DecidableEq β
f : α → β
s : Multiset α
hf : Set.InjOn f {x | x ∈ s}
x : α
H : x ∈ s
⊢ count x (filter (fun a => f x = f a) s) = card (filter (fun a => f x = f a) s)

tactic: rw [count, countP_map, ← this]
state_before: α : Type u_1
β : Type v
γ : Type u_2
inst✝¹ : DecidableEq α
s✝ : Multiset α
inst✝ : DecidableEq β
f : α → β
s : Multiset α
hf : Set.InjOn f {x | x ∈ s}
x : α
H : x ∈ s
this : count x (filter (fun a => f x = f a) s) = card (filter (fun a => f x = f a) s)
⊢ count (f x) (map f s) = count x s
state_after: α : Type u_1
β : Type v
γ : Type u_2
inst✝¹ : DecidableEq α
s✝ : Multiset α
inst✝ : DecidableEq β
f : α → β
s : Multiset α
hf : Set.InjOn f {x | x ∈ s}
x : α
H : x ∈ s
this : count x (filter (fun a => f x = f a) s) = card (filter (fun a => f x = f a) s)
⊢ count x (filter (fun a => f x = f a) s) = count x s

tactic: exact count_filter_of_pos <| rfl
state_before: α : Type u_1
β : Type v
γ : Type u_2
inst✝¹ : DecidableEq α
s✝ : Multiset α
inst✝ : DecidableEq β
f : α → β
s : Multiset α
hf : Set.InjOn f {x | x ∈ s}
x : α
H : x ∈ s
this : count x (filter (fun a => f x = f a) s) = card (filter (fun a => f x = f a) s)
⊢ count x (filter (fun a => f x = f a) s) = count x s
state_after: no goals

tactic: rw [eq_replicate_card.2 fun b hb => (hf H (mem_filter.1 hb).left _).symm]
state_before: α : Type u_1
β : Type v
γ : Type u_2
inst✝¹ : DecidableEq α
s✝ : Multiset α
inst✝ : DecidableEq β
f : α → β
s : Multiset α
hf : Set.InjOn f {x | x ∈ s}
x : α
H : x ∈ s
⊢ count x (filter (fun a => f x = f a) s) = card (filter (fun a => f x = f a) s)
state_after: α : Type u_1
β : Type v
γ : Type u_2
inst✝¹ : DecidableEq α
s✝ : Multiset α
inst✝ : DecidableEq β
f : α → β
s : Multiset α
hf : Set.InjOn f {x | x ∈ s}
x : α
H : x ∈ s
⊢ count x (replicate (card (filter (fun a => f x = f a) s)) x) =
    card (replicate (card (filter (fun a => f x = f a) s)) x)

α : Type u_1
β : Type v
γ : Type u_2
inst✝¹ : DecidableEq α
s✝ : Multiset α
inst✝ : DecidableEq β
f : α → β
s : Multiset α
hf : Set.InjOn f {x | x ∈ s}
x : α
H : x ∈ s
⊢ ∀ b ∈ filter (fun a => f x = f a) s, f x = f b

tactic: simp only [count_replicate, eq_self_iff_true, if_true, card_replicate]
state_before: α : Type u_1
β : Type v
γ : Type u_2
inst✝¹ : DecidableEq α
s✝ : Multiset α
inst✝ : DecidableEq β
f : α → β
s : Multiset α
hf : Set.InjOn f {x | x ∈ s}
x : α
H : x ∈ s
⊢ count x (replicate (card (filter (fun a => f x = f a) s)) x) =
    card (replicate (card (filter (fun a => f x = f a) s)) x)
state_after: no goals

tactic: simp only [mem_filter, beq_iff_eq, and_imp, @eq_comm _ (f x), imp_self, implies_true]
state_before: α : Type u_1
β : Type v
γ : Type u_2
inst✝¹ : DecidableEq α
s✝ : Multiset α
inst✝ : DecidableEq β
f : α → β
s : Multiset α
hf : Set.InjOn f {x | x ∈ s}
x : α
H : x ∈ s
⊢ ∀ b ∈ filter (fun a => f x = f a) s, f x = f b
state_after: no goals