-- Mathlib/Algebra/Group/UniqueProds/Basic.lean
theorem of_image_filter [DecidableEq H]
    (f : G →ₙ* H) {A B : Finset G} {aG bG : G} {aH bH : H} (hae : f aG = aH) (hbe : f bG = bH)
    (huH : UniqueMul (A.image f) (B.image f) aH bH)
    (huG : UniqueMul {a ∈ A | f a = aH} {b ∈ B | f b = bH} aG bG) :
    UniqueMul A B aG bG := fun a b ha hb he ↦ by
  specialize huH (mem_image_of_mem _ ha) (mem_image_of_mem _ hb)
  rw [← map_mul, he, map_mul, hae, hbe] at huH
  refine huG ?_ ?_ he <;> rw [mem_filter]
  exacts [⟨ha, (huH rfl).1⟩, ⟨hb, (huH rfl).2⟩]

Proof state:
G : Type u_1
H : Type u_2
inst✝² : Mul G
inst✝¹ : Mul H
inst✝ : DecidableEq H
f : G →ₙ* H
A B : Finset G
aG bG : G
aH bH : H
hae : f aG = aH
hbe : f bG = bH
huG : UniqueMul (filter (fun a => f a = aH) A) (filter (fun b => f b = bH) B) aG bG
a b : G
ha : a ∈ A
hb : b ∈ B
he : a * b = aG * bG
huH : aH * bH = aH * bH → f a = aH ∧ f b = bH
⊢ a = aG ∧ b = bG

Tactic:
refine huG ?_ ?_ he <;> rw [mem_filter]

Result:
case refine_1
G : Type u_1
H : Type u_2
inst✝² : Mul G
inst✝¹ : Mul H
inst✝ : DecidableEq H
f : G →ₙ* H
A B : Finset G
aG bG : G
aH bH : H
hae : f aG = aH
hbe : f bG = bH
huG : UniqueMul (filter (fun a => f a = aH) A) (filter (fun b => f b = bH) B) aG bG
a b : G
ha : a ∈ A
hb : b ∈ B
he : a * b = aG * bG
huH : aH * bH = aH * bH → f a = aH ∧ f b = bH
⊢ a ∈ A ∧ f a = aH

case refine_2
G : Type u_1
H : Type u_2
inst✝² : Mul G
inst✝¹ : Mul H
inst✝ : DecidableEq H
f : G →ₙ* H
A B : Finset G
aG bG : G
aH bH : H
hae : f aG = aH
hbe : f bG = bH
huG : UniqueMul (filter (fun a => f a = aH) A) (filter (fun b => f b = bH) B) aG bG
a b : G
ha : a ∈ A
hb : b ∈ B
he : a * b = aG * bG
huH : aH * bH = aH * bH → f a = aH ∧ f b = bH
⊢ b ∈ B ∧ f b = bH

Proof state:
case refine_1
G : Type u_1
H : Type u_2
inst✝² : Mul G
inst✝¹ : Mul H
inst✝ : DecidableEq H
f : G →ₙ* H
A B : Finset G
aG bG : G
aH bH : H
hae : f aG = aH
hbe : f bG = bH
huG : UniqueMul (filter (fun a => f a = aH) A) (filter (fun b => f b = bH) B) aG bG
a b : G
ha : a ∈ A
hb : b ∈ B
he : a * b = aG * bG
huH : aH * bH = aH * bH → f a = aH ∧ f b = bH
⊢ a ∈ A ∧ f a = aH

case refine_2
G : Type u_1
H : Type u_2
inst✝² : Mul G
inst✝¹ : Mul H
inst✝ : DecidableEq H
f : G →ₙ* H
A B : Finset G
aG bG : G
aH bH : H
hae : f aG = aH
hbe : f bG = bH
huG : UniqueMul (filter (fun a => f a = aH) A) (filter (fun b => f b = bH) B) aG bG
a b : G
ha : a ∈ A
hb : b ∈ B
he : a * b = aG * bG
huH : aH * bH = aH * bH → f a = aH ∧ f b = bH
⊢ b ∈ B ∧ f b = bH

Tactic:
exacts [⟨ha, (huH rfl).1⟩, ⟨hb, (huH rfl).2⟩]

Result:
no goals

Proof state:
G : Type u_1
H : Type u_2
inst✝² : Mul G
inst✝¹ : Mul H
inst✝ : DecidableEq H
f : G →ₙ* H
A B : Finset G
aG bG : G
aH bH : H
hae : f aG = aH
hbe : f bG = bH
huG : UniqueMul (filter (fun a => f a = aH) A) (filter (fun b => f b = bH) B) aG bG
a b : G
ha : a ∈ A
hb : b ∈ B
he : a * b = aG * bG
huH : f a * f b = aH * bH → f a = aH ∧ f b = bH
⊢ a = aG ∧ b = bG

Tactic:
rw [← map_mul, he, map_mul, hae, hbe] at huH

Result:
G : Type u_1
H : Type u_2
inst✝² : Mul G
inst✝¹ : Mul H
inst✝ : DecidableEq H
f : G →ₙ* H
A B : Finset G
aG bG : G
aH bH : H
hae : f aG = aH
hbe : f bG = bH
huG : UniqueMul (filter (fun a => f a = aH) A) (filter (fun b => f b = bH) B) aG bG
a b : G
ha : a ∈ A
hb : b ∈ B
he : a * b = aG * bG
huH : aH * bH = aH * bH → f a = aH ∧ f b = bH
⊢ a = aG ∧ b = bG

Proof state:
G : Type u_1
H : Type u_2
inst✝² : Mul G
inst✝¹ : Mul H
inst✝ : DecidableEq H
f : G →ₙ* H
A B : Finset G
aG bG : G
aH bH : H
hae : f aG = aH
hbe : f bG = bH
huH : UniqueMul (image (⇑f) A) (image (⇑f) B) aH bH
huG : UniqueMul (filter (fun a => f a = aH) A) (filter (fun b => f b = bH) B) aG bG
a b : G
ha : a ∈ A
hb : b ∈ B
he : a * b = aG * bG
⊢ a = aG ∧ b = bG

Tactic:
specialize huH (mem_image_of_mem _ ha) (mem_image_of_mem _ hb)

Result:
G : Type u_1
H : Type u_2
inst✝² : Mul G
inst✝¹ : Mul H
inst✝ : DecidableEq H
f : G →ₙ* H
A B : Finset G
aG bG : G
aH bH : H
hae : f aG = aH
hbe : f bG = bH
huG : UniqueMul (filter (fun a => f a = aH) A) (filter (fun b => f b = bH) B) aG bG
a b : G
ha : a ∈ A
hb : b ∈ B
he : a * b = aG * bG
huH : f a * f b = aH * bH → f a = aH ∧ f b = bH
⊢ a = aG ∧ b = bG