Theorem: Grp.SurjectiveOfEpiAuxs.agree
File: Mathlib/Algebra/Category/Grp/EpiMono.lean

tactic: refine Set.ext fun b => ⟨?_, fun hb : h b = g b => by_contradiction fun r => ?_⟩
state_before: A B : Grp
f : A ⟶ B
⊢ ↑(MonoidHom.range f) = {x | h x = g x}
state_after: case refine_1
A B : Grp
f : A ⟶ B
b : ↑B
⊢ b ∈ ↑(MonoidHom.range f) → b ∈ {x | h x = g x}

case refine_2
A B : Grp
f : A ⟶ B
b : ↑B
hb : h b = g b
r : b ∉ ↑(MonoidHom.range f)
⊢ False

tactic: rintro ⟨a, rfl⟩
state_before: case refine_1
A B : Grp
f : A ⟶ B
b : ↑B
⊢ b ∈ ↑(MonoidHom.range f) → b ∈ {x | h x = g x}
state_after: case refine_1.intro
A B : Grp
f : A ⟶ B
a : ↑A
⊢ f a ∈ {x | h x = g x}

tactic: change h (f a) = g (f a)
state_before: case refine_1.intro
A B : Grp
f : A ⟶ B
a : ↑A
⊢ f a ∈ {x | h x = g x}
state_after: case refine_1.intro
A B : Grp
f : A ⟶ B
a : ↑A
⊢ h (f a) = g (f a)

tactic: ext ⟨⟨_, ⟨y, rfl⟩⟩⟩
state_before: case refine_1.intro
A B : Grp
f : A ⟶ B
a : ↑A
⊢ h (f a) = g (f a)
state_after: case refine_1.intro.H.fromCoset.mk.intro
A B : Grp
f : A ⟶ B
a : ↑A
y : ↑B
⊢ (h (f a)) (fromCoset ⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩) =
    (g (f a)) (fromCoset ⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩)

case refine_1.intro.H.infinity
A B : Grp
f : A ⟶ B
a : ↑A
⊢ (h (f a)) ∞ = (g (f a)) ∞

tactic: rw [g_apply_fromCoset]
state_before: case refine_1.intro.H.fromCoset.mk.intro
A B : Grp
f : A ⟶ B
a : ↑A
y : ↑B
⊢ (h (f a)) (fromCoset ⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩) =
    (g (f a)) (fromCoset ⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩)
state_after: case refine_1.intro.H.fromCoset.mk.intro
A B : Grp
f : A ⟶ B
a : ↑A
y : ↑B
⊢ (h (f a)) (fromCoset ⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩) =
    fromCoset ⟨f a • ↑⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩, ⋯⟩

tactic: by_cases m : y ∈ f.range
state_before: case refine_1.intro.H.fromCoset.mk.intro
A B : Grp
f : A ⟶ B
a : ↑A
y : ↑B
⊢ (h (f a)) (fromCoset ⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩) =
    fromCoset ⟨f a • ↑⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩, ⋯⟩
state_after: case pos
A B : Grp
f : A ⟶ B
a : ↑A
y : ↑B
m : y ∈ MonoidHom.range f
⊢ (h (f a)) (fromCoset ⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩) =
    fromCoset ⟨f a • ↑⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩, ⋯⟩

case neg
A B : Grp
f : A ⟶ B
a : ↑A
y : ↑B
m : y ∉ MonoidHom.range f
⊢ (h (f a)) (fromCoset ⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩) =
    fromCoset ⟨f a • ↑⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩, ⋯⟩

tactic: rw [h_apply_fromCoset' _ _ _ m, fromCoset_eq_of_mem_range _ m]
state_before: case pos
A B : Grp
f : A ⟶ B
a : ↑A
y : ↑B
m : y ∈ MonoidHom.range f
⊢ (h (f a)) (fromCoset ⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩) =
    fromCoset ⟨f a • ↑⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩, ⋯⟩
state_after: case pos
A B : Grp
f : A ⟶ B
a : ↑A
y : ↑B
m : y ∈ MonoidHom.range f
⊢ fromCoset ⟨↑(MonoidHom.range f), ⋯⟩ = fromCoset ⟨f a • ↑⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩, ⋯⟩

tactic: change fromCoset _ = fromCoset ⟨f a • (y • _), _⟩
state_before: case pos
A B : Grp
f : A ⟶ B
a : ↑A
y : ↑B
m : y ∈ MonoidHom.range f
⊢ fromCoset ⟨↑(MonoidHom.range f), ⋯⟩ = fromCoset ⟨f a • ↑⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩, ⋯⟩
state_after: case pos
A B : Grp
f : A ⟶ B
a : ↑A
y : ↑B
m : y ∈ MonoidHom.range f
⊢ fromCoset ⟨↑(MonoidHom.range f), ⋯⟩ = fromCoset ⟨f a • y • ↑(MonoidHom.range f), ⋯⟩

tactic: simp only [← fromCoset_eq_of_mem_range _ (Subgroup.mul_mem _ ⟨a, rfl⟩ m), smul_smul]
state_before: case pos
A B : Grp
f : A ⟶ B
a : ↑A
y : ↑B
m : y ∈ MonoidHom.range f
⊢ fromCoset ⟨↑(MonoidHom.range f), ⋯⟩ = fromCoset ⟨f a • y • ↑(MonoidHom.range f), ⋯⟩
state_after: no goals

tactic: rw [h_apply_fromCoset_nin_range f (f a) ⟨_, rfl⟩ _ m]
state_before: case neg
A B : Grp
f : A ⟶ B
a : ↑A
y : ↑B
m : y ∉ MonoidHom.range f
⊢ (h (f a)) (fromCoset ⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩) =
    fromCoset ⟨f a • ↑⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩, ⋯⟩
state_after: case neg
A B : Grp
f : A ⟶ B
a : ↑A
y : ↑B
m : y ∉ MonoidHom.range f
⊢ fromCoset ⟨(f a * y) • ↑(MonoidHom.range f), ⋯⟩ = fromCoset ⟨f a • ↑⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩, ⋯⟩

tactic: simp only [leftCoset_assoc]
state_before: case neg
A B : Grp
f : A ⟶ B
a : ↑A
y : ↑B
m : y ∉ MonoidHom.range f
⊢ fromCoset ⟨(f a * y) • ↑(MonoidHom.range f), ⋯⟩ = fromCoset ⟨f a • ↑⟨(fun x => x • ↑(MonoidHom.range f)) y, ⋯⟩, ⋯⟩
state_after: no goals

tactic: rw [g_apply_infinity, h_apply_infinity f (f a) ⟨_, rfl⟩]
state_before: case refine_1.intro.H.infinity
A B : Grp
f : A ⟶ B
a : ↑A
⊢ (h (f a)) ∞ = (g (f a)) ∞
state_after: no goals

tactic: have eq1 : (h b) (fromCoset ⟨f.range, 1, one_leftCoset _⟩) =
    fromCoset ⟨f.range, 1, one_leftCoset _⟩ := by
  change ((τ).symm.trans (g b)).trans τ _ = _
  dsimp [tau]
  simp [g_apply_infinity f]
state_before: case refine_2
A B : Grp
f : A ⟶ B
b : ↑B
hb : h b = g b
r : b ∉ ↑(MonoidHom.range f)
⊢ False
state_after: case refine_2
A B : Grp
f : A ⟶ B
b : ↑B
hb : h b = g b
r : b ∉ ↑(MonoidHom.range f)
eq1 : (h b) (fromCoset ⟨↑(MonoidHom.range f), ⋯⟩) = fromCoset ⟨↑(MonoidHom.range f), ⋯⟩
⊢ False

tactic: have eq2 :
  g b (fromCoset ⟨f.range, 1, one_leftCoset _⟩) = fromCoset ⟨b • ↑f.range, b, rfl⟩ := rfl
state_before: case refine_2
A B : Grp
f : A ⟶ B
b : ↑B
hb : h b = g b
r : b ∉ ↑(MonoidHom.range f)
eq1 : (h b) (fromCoset ⟨↑(MonoidHom.range f), ⋯⟩) = fromCoset ⟨↑(MonoidHom.range f), ⋯⟩
⊢ False
state_after: case refine_2
A B : Grp
f : A ⟶ B
b : ↑B
hb : h b = g b
r : b ∉ ↑(MonoidHom.range f)
eq1 : (h b) (fromCoset ⟨↑(MonoidHom.range f), ⋯⟩) = fromCoset ⟨↑(MonoidHom.range f), ⋯⟩
eq2 : (g b) (fromCoset ⟨↑(MonoidHom.range f), ⋯⟩) = fromCoset ⟨b • ↑(MonoidHom.range f), ⋯⟩
⊢ False

tactic: exact (fromCoset_ne_of_nin_range _ r).symm (by rw [← eq1, ← eq2, DFunLike.congr_fun hb])
state_before: case refine_2
A B : Grp
f : A ⟶ B
b : ↑B
hb : h b = g b
r : b ∉ ↑(MonoidHom.range f)
eq1 : (h b) (fromCoset ⟨↑(MonoidHom.range f), ⋯⟩) = fromCoset ⟨↑(MonoidHom.range f), ⋯⟩
eq2 : (g b) (fromCoset ⟨↑(MonoidHom.range f), ⋯⟩) = fromCoset ⟨b • ↑(MonoidHom.range f), ⋯⟩
⊢ False
state_after: no goals

tactic: change ((τ).symm.trans (g b)).trans τ _ = _
state_before: A B : Grp
f : A ⟶ B
b : ↑B
hb : h b = g b
r : b ∉ ↑(MonoidHom.range f)
⊢ (h b) (fromCoset ⟨↑(MonoidHom.range f), ⋯⟩) = fromCoset ⟨↑(MonoidHom.range f), ⋯⟩
state_after: A B : Grp
f : A ⟶ B
b : ↑B
hb : h b = g b
r : b ∉ ↑(MonoidHom.range f)
⊢ (((Equiv.symm τ).trans (g b)).trans τ) (fromCoset ⟨↑(MonoidHom.range f), ⋯⟩) = fromCoset ⟨↑(MonoidHom.range f), ⋯⟩

tactic: dsimp [tau]
state_before: A B : Grp
f : A ⟶ B
b : ↑B
hb : h b = g b
r : b ∉ ↑(MonoidHom.range f)
⊢ (((Equiv.symm τ).trans (g b)).trans τ) (fromCoset ⟨↑(MonoidHom.range f), ⋯⟩) = fromCoset ⟨↑(MonoidHom.range f), ⋯⟩
state_after: A B : Grp
f : A ⟶ B
b : ↑B
hb : h b = g b
r : b ∉ ↑(MonoidHom.range f)
⊢ (Equiv.swap (fromCoset ⟨Set.range ⇑f, ⋯⟩) ∞)
      ((g b) ((Equiv.swap (fromCoset ⟨Set.range ⇑f, ⋯⟩) ∞) (fromCoset ⟨Set.range ⇑f, ⋯⟩))) =
    fromCoset ⟨Set.range ⇑f, ⋯⟩

tactic: simp [g_apply_infinity f]
state_before: A B : Grp
f : A ⟶ B
b : ↑B
hb : h b = g b
r : b ∉ ↑(MonoidHom.range f)
⊢ (Equiv.swap (fromCoset ⟨Set.range ⇑f, ⋯⟩) ∞)
      ((g b) ((Equiv.swap (fromCoset ⟨Set.range ⇑f, ⋯⟩) ∞) (fromCoset ⟨Set.range ⇑f, ⋯⟩))) =
    fromCoset ⟨Set.range ⇑f, ⋯⟩
state_after: no goals

tactic: rw [← eq1, ← eq2, DFunLike.congr_fun hb]
state_before: A B : Grp
f : A ⟶ B
b : ↑B
hb : h b = g b
r : b ∉ ↑(MonoidHom.range f)
eq1 : (h b) (fromCoset ⟨↑(MonoidHom.range f), ⋯⟩) = fromCoset ⟨↑(MonoidHom.range f), ⋯⟩
eq2 : (g b) (fromCoset ⟨↑(MonoidHom.range f), ⋯⟩) = fromCoset ⟨b • ↑(MonoidHom.range f), ⋯⟩
⊢ fromCoset ⟨↑(MonoidHom.range f), ⋯⟩ = fromCoset ⟨b • ↑(MonoidHom.range f), ⋯⟩
state_after: no goals