l3lab/ntp-mathlib huggingface dataset:
instance gradeBy.gradedAlgebra : GradedAlgebra (gradeBy R f) :=
  GradedAlgebra.ofAlgHom _ (decomposeAux f)
    (by
      ext : 2
      simp only [MonoidHom.coe_comp, MonoidHom.coe_coe, AlgHom.coe_comp, Function.comp_apply,
        of_apply, AlgHom.coe_id, id_eq]
      

Proof state:
case h.h
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝⁴ : DecidableEq M
inst✝³ : AddMonoid M
inst✝² : DecidableEq ι
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
x✝ : Multiplicative M
⊢ (coeAlgHom (gradeBy R ⇑f)) ((decomposeAux f) (single (Multiplicative.toAdd x✝) 1)) =
    single (Multiplicative.toAdd x✝) 1

Next tactic:
rw [decomposeAux_single, DirectSum.coeAlgHom_of, Subtype.coe_mk]
instance gradeBy.gradedAlgebra : GradedAlgebra (gradeBy R f) :=
  GradedAlgebra.ofAlgHom _ (decomposeAux f)
    (by
      ext : 2
      simp only [MonoidHom.coe_comp, MonoidHom.coe_coe, AlgHom.coe_comp, Function.comp_apply,
        of_apply, AlgHom.coe_id, id_eq]
      rw [decomposeAux_single, DirectSum.coeAlgHom_of, Subtype.coe_mk])
    fun i x => by 

Proof state:
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝⁴ : DecidableEq M
inst✝³ : AddMonoid M
inst✝² : DecidableEq ι
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
i : ι
x : ↥(gradeBy R (⇑f) i)
⊢ (decomposeAux f) ↑x = (DirectSum.of (fun i => ↥(gradeBy R (⇑f) i)) i) x

Next tactic:
rw [decomposeAux_coe f x]
instance gradeBy.decomposition : DirectSum.Decomposition (gradeBy R f) := by 

Proof state:
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝⁴ : DecidableEq M
inst✝³ : AddMonoid M
inst✝² : DecidableEq ι
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
⊢ Decomposition (gradeBy R ⇑f)

Next tactic:
infer_instance
instance grade.decomposition : DirectSum.Decomposition (grade R : ι → Submodule _ _) := by
  

Proof state:
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝⁴ : DecidableEq M
inst✝³ : AddMonoid M
inst✝² : DecidableEq ι
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
⊢ Decomposition (grade R)

Next tactic:
infer_instance
@[to_additive]
theorem Supports.smul (g : H) (h : Supports G s b) : Supports G (g • s) (g • b) := by
  

Proof state:
G : Type u_1
H : Type u_2
α : Type u_3
β : Type u_4
inst✝⁶ : Group H
inst✝⁵ : SMul G α
inst✝⁴ : SMul G β
inst✝³ : MulAction H α
inst✝² : SMul H β
inst✝¹ : SMulCommClass G H β
inst✝ : SMulCommClass G H α
s t : Set α
b : β
g : H
h : Supports G s b
⊢ Supports G (g • s) (g • b)

Next tactic:
rintro g' hg'
@[to_additive]
theorem Supports.smul (g : H) (h : Supports G s b) : Supports G (g • s) (g • b) := by
  rintro g' hg'
  

Proof state:
G : Type u_1
H : Type u_2
α : Type u_3
β : Type u_4
inst✝⁶ : Group H
inst✝⁵ : SMul G α
inst✝⁴ : SMul G β
inst✝³ : MulAction H α
inst✝² : SMul H β
inst✝¹ : SMulCommClass G H β
inst✝ : SMulCommClass G H α
s t : Set α
b : β
g : H
h : Supports G s b
g' : G
hg' : ∀ ⦃a : α⦄, a ∈ g • s → g' • a = a
⊢ g' • g • b = g • b

Next tactic:
rw [smul_comm, h]
@[to_additive]
theorem Supports.smul (g : H) (h : Supports G s b) : Supports G (g • s) (g • b) := by
  rintro g' hg'
  rw [smul_comm, h]
  

Proof state:
case a
G : Type u_1
H : Type u_2
α : Type u_3
β : Type u_4
inst✝⁶ : Group H
inst✝⁵ : SMul G α
inst✝⁴ : SMul G β
inst✝³ : MulAction H α
inst✝² : SMul H β
inst✝¹ : SMulCommClass G H β
inst✝ : SMulCommClass G H α
s t : Set α
b : β
g : H
h : Supports G s b
g' : G
hg' : ∀ ⦃a : α⦄, a ∈ g • s → g' • a = a
⊢ ∀ ⦃a : α⦄, a ∈ s → g' • a = a

Next tactic:
rintro a ha
@[to_additive]
theorem Supports.smul (g : H) (h : Supports G s b) : Supports G (g • s) (g • b) := by
  rintro g' hg'
  rw [smul_comm, h]
  rintro a ha
  

Proof state:
case a
G : Type u_1
H : Type u_2
α : Type u_3
β : Type u_4
inst✝⁶ : Group H
inst✝⁵ : SMul G α
inst✝⁴ : SMul G β
inst✝³ : MulAction H α
inst✝² : SMul H β
inst✝¹ : SMulCommClass G H β
inst✝ : SMulCommClass G H α
s t : Set α
b : β
g : H
h : Supports G s b
g' : G
hg' : ∀ ⦃a : α⦄, a ∈ g • s → g' • a = a
a : α
ha : a ∈ s
⊢ g' • a = a

Next tactic:
have := Set.ball_image_iff.1 hg' a ha
@[to_additive]
theorem Supports.smul (g : H) (h : Supports G s b) : Supports G (g • s) (g • b) := by
  rintro g' hg'
  rw [smul_comm, h]
  rintro a ha
  have := Set.ball_image_iff.1 hg' a ha
  

Proof state:
case a
G : Type u_1
H : Type u_2
α : Type u_3
β : Type u_4
inst✝⁶ : Group H
inst✝⁵ : SMul G α
inst✝⁴ : SMul G β
inst✝³ : MulAction H α
inst✝² : SMul H β
inst✝¹ : SMulCommClass G H β
inst✝ : SMulCommClass G H α
s t : Set α
b : β
g : H
h : Supports G s b
g' : G
hg' : ∀ ⦃a : α⦄, a ∈ g • s → g' • a = a
a : α
ha : a ∈ s
this : g' • g • a = g • a
⊢ g' • a = a

Next tactic:
rwa [smul_comm, smul_left_cancel_iff] at this
/--
Implementation: If `π` is a surjective morphism in `Profinite`, then it is an effective epi.
The theorem `Profinite.effectiveEpi_tfae` should be used instead.
-/
noncomputable
def struct {B X : Profinite.{u}} (π : X ⟶ B) (hπ : Function.Surjective π) :
    EffectiveEpiStruct π where
  desc e h := (QuotientMap.of_surjective_continuous hπ π.continuous).lift e fun a b hab ↦
    FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by 

Proof state:
B X : Profinite
π : X ⟶ B
hπ : Function.Surjective ⇑π
W✝ : Profinite
e : X ⟶ W✝
h : ∀ {Z : Profinite} (g₁ g₂ : Z ⟶ X), g₁ ≫ π = g₂ ≫ π → g₁ ≫ e = g₂ ≫ e
a b : (forget Profinite).obj X
hab : π a = π b
⊢ (ContinuousMap.mk fun x => a) ≫ π = (ContinuousMap.mk fun x => b) ≫ π

Next tactic:
ext
/--
Implementation: If `π` is a surjective morphism in `Profinite`, then it is an effective epi.
The theorem `Profinite.effectiveEpi_tfae` should be used instead.
-/
noncomputable
def struct {B X : Profinite.{u}} (π : X ⟶ B) (hπ : Function.Surjective π) :
    EffectiveEpiStruct π where
  desc e h := (QuotientMap.of_surjective_continuous hπ π.continuous).lift e fun a b hab ↦
    FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; 

Proof state:
case w
B X : Profinite
π : X ⟶ B
hπ : Function.Surjective ⇑π
W✝ : Profinite
e : X ⟶ W✝
h : ∀ {Z : Profinite} (g₁ g₂ : Z ⟶ X), g₁ ≫ π = g₂ ≫ π → g₁ ≫ e = g₂ ≫ e
a b : (forget Profinite).obj X
hab : π a = π b
x✝ : (forget Profinite).obj X
⊢ ((ContinuousMap.mk fun x => a) ≫ π) x✝ = ((ContinuousMap.mk fun x => b) ≫ π) x✝

Next tactic:
exact hab
/--
Implementation: If `π` is a surjective morphism in `Profinite`, then it is an effective epi.
The theorem `Profinite.effectiveEpi_tfae` should be used instead.
-/
noncomputable
def struct {B X : Profinite.{u}} (π : X ⟶ B) (hπ : Function.Surjective π) :
    EffectiveEpiStruct π where
  desc e h := (QuotientMap.of_surjective_continuous hπ π.continuous).lift e fun a b hab ↦
    FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; exact hab)) a
  fac e h := ((QuotientMap.of_surjective_continuous hπ π.continuous).lift_comp e
    fun a b hab ↦ FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by 

Proof state:
B X : Profinite
π : X ⟶ B
hπ : Function.Surjective ⇑π
W✝ : Profinite
e : X ⟶ W✝
h : ∀ {Z : Profinite} (g₁ g₂ : Z ⟶ X), g₁ ≫ π = g₂ ≫ π → g₁ ≫ e = g₂ ≫ e
a b : (forget Profinite).obj X
hab : π a = π b
⊢ (ContinuousMap.mk fun x => a) ≫ π = (ContinuousMap.mk fun x => b) ≫ π

Next tactic:
ext
/--
Implementation: If `π` is a surjective morphism in `Profinite`, then it is an effective epi.
The theorem `Profinite.effectiveEpi_tfae` should be used instead.
-/
noncomputable
def struct {B X : Profinite.{u}} (π : X ⟶ B) (hπ : Function.Surjective π) :
    EffectiveEpiStruct π where
  desc e h := (QuotientMap.of_surjective_continuous hπ π.continuous).lift e fun a b hab ↦
    FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; exact hab)) a
  fac e h := ((QuotientMap.of_surjective_continuous hπ π.continuous).lift_comp e
    fun a b hab ↦ FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; 

Proof state:
case w
B X : Profinite
π : X ⟶ B
hπ : Function.Surjective ⇑π
W✝ : Profinite
e : X ⟶ W✝
h : ∀ {Z : Profinite} (g₁ g₂ : Z ⟶ X), g₁ ≫ π = g₂ ≫ π → g₁ ≫ e = g₂ ≫ e
a b : (forget Profinite).obj X
hab : π a = π b
x✝ : (forget Profinite).obj X
⊢ ((ContinuousMap.mk fun x => a) ≫ π) x✝ = ((ContinuousMap.mk fun x => b) ≫ π) x✝

Next tactic:
exact hab
/--
Implementation: If `π` is a surjective morphism in `Profinite`, then it is an effective epi.
The theorem `Profinite.effectiveEpi_tfae` should be used instead.
-/
noncomputable
def struct {B X : Profinite.{u}} (π : X ⟶ B) (hπ : Function.Surjective π) :
    EffectiveEpiStruct π where
  desc e h := (QuotientMap.of_surjective_continuous hπ π.continuous).lift e fun a b hab ↦
    FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; exact hab)) a
  fac e h := ((QuotientMap.of_surjective_continuous hπ π.continuous).lift_comp e
    fun a b hab ↦ FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; exact hab)) a)
  uniq e h g hm := by
    

Proof state:
B X : Profinite
π : X ⟶ B
hπ : Function.Surjective ⇑π
W✝ : Profinite
e : X ⟶ W✝
h : ∀ {Z : Profinite} (g₁ g₂ : Z ⟶ X), g₁ ≫ π = g₂ ≫ π → g₁ ≫ e = g₂ ≫ e
g : B ⟶ W✝
hm : π ≫ g = e
⊢ g =
    (fun {W} e h =>
        QuotientMap.lift (_ : QuotientMap ⇑π) e
          (_ :
            ∀ (a b : (forget Profinite).obj X),
              π a = π b → ((ContinuousMap.mk fun x => a) ≫ e) a = ((ContinuousMap.mk fun x => b) ≫ e) a))
      e (_ : ∀ {Z : Profinite} (g₁ g₂ : Z ⟶ X), g₁ ≫ π = g₂ ≫ π → g₁ ≫ e = g₂ ≫ e)

Next tactic:
suffices g = (QuotientMap.of_surjective_continuous hπ π.continuous).liftEquiv ⟨e,
      fun a b hab ↦ FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
      (by ext; exact hab)) a⟩ by assumption
/--
Implementation: If `π` is a surjective morphism in `Profinite`, then it is an effective epi.
The theorem `Profinite.effectiveEpi_tfae` should be used instead.
-/
noncomputable
def struct {B X : Profinite.{u}} (π : X ⟶ B) (hπ : Function.Surjective π) :
    EffectiveEpiStruct π where
  desc e h := (QuotientMap.of_surjective_continuous hπ π.continuous).lift e fun a b hab ↦
    FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; exact hab)) a
  fac e h := ((QuotientMap.of_surjective_continuous hπ π.continuous).lift_comp e
    fun a b hab ↦ FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; exact hab)) a)
  uniq e h g hm := by
    suffices g = (QuotientMap.of_surjective_continuous hπ π.continuous).liftEquiv ⟨e,
      fun a b hab ↦ FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
      (by 

Proof state:
B X : Profinite
π : X ⟶ B
hπ : Function.Surjective ⇑π
W✝ : Profinite
e : X ⟶ W✝
h : ∀ {Z : Profinite} (g₁ g₂ : Z ⟶ X), g₁ ≫ π = g₂ ≫ π → g₁ ≫ e = g₂ ≫ e
g : B ⟶ W✝
hm : π ≫ g = e
a b : (forget Profinite).obj X
hab : π a = π b
⊢ (ContinuousMap.mk fun x => a) ≫ π = (ContinuousMap.mk fun x => b) ≫ π

Next tactic:
ext
/--
Implementation: If `π` is a surjective morphism in `Profinite`, then it is an effective epi.
The theorem `Profinite.effectiveEpi_tfae` should be used instead.
-/
noncomputable
def struct {B X : Profinite.{u}} (π : X ⟶ B) (hπ : Function.Surjective π) :
    EffectiveEpiStruct π where
  desc e h := (QuotientMap.of_surjective_continuous hπ π.continuous).lift e fun a b hab ↦
    FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; exact hab)) a
  fac e h := ((QuotientMap.of_surjective_continuous hπ π.continuous).lift_comp e
    fun a b hab ↦ FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; exact hab)) a)
  uniq e h g hm := by
    suffices g = (QuotientMap.of_surjective_continuous hπ π.continuous).liftEquiv ⟨e,
      fun a b hab ↦ FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
      (by ext; 

Proof state:
case w
B X : Profinite
π : X ⟶ B
hπ : Function.Surjective ⇑π
W✝ : Profinite
e : X ⟶ W✝
h : ∀ {Z : Profinite} (g₁ g₂ : Z ⟶ X), g₁ ≫ π = g₂ ≫ π → g₁ ≫ e = g₂ ≫ e
g : B ⟶ W✝
hm : π ≫ g = e
a b : (forget Profinite).obj X
hab : π a = π b
x✝ : (forget Profinite).obj X
⊢ ((ContinuousMap.mk fun x => a) ≫ π) x✝ = ((ContinuousMap.mk fun x => b) ≫ π) x✝

Next tactic:
exact hab
/--
Implementation: If `π` is a surjective morphism in `Profinite`, then it is an effective epi.
The theorem `Profinite.effectiveEpi_tfae` should be used instead.
-/
noncomputable
def struct {B X : Profinite.{u}} (π : X ⟶ B) (hπ : Function.Surjective π) :
    EffectiveEpiStruct π where
  desc e h := (QuotientMap.of_surjective_continuous hπ π.continuous).lift e fun a b hab ↦
    FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; exact hab)) a
  fac e h := ((QuotientMap.of_surjective_continuous hπ π.continuous).lift_comp e
    fun a b hab ↦ FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; exact hab)) a)
  uniq e h g hm := by
    suffices g = (QuotientMap.of_surjective_continuous hπ π.continuous).liftEquiv ⟨e,
      fun a b hab ↦ FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
      (by ext; exact hab)) a⟩ by 

Proof state:
B X : Profinite
π : X ⟶ B
hπ : Function.Surjective ⇑π
W✝ : Profinite
e : X ⟶ W✝
h : ∀ {Z : Profinite} (g₁ g₂ : Z ⟶ X), g₁ ≫ π = g₂ ≫ π → g₁ ≫ e = g₂ ≫ e
g : B ⟶ W✝
hm : π ≫ g = e
this :
  g =
    (QuotientMap.liftEquiv (_ : QuotientMap ⇑π))
      { val := e,
        property :=
          (_ :
            ∀ (a b : (forget Profinite).obj X),
              π a = π b → ((ContinuousMap.mk fun x => a) ≫ e) a = ((ContinuousMap.mk fun x => b) ≫ e) a) }
⊢ g =
    (fun {W} e h =>
        QuotientMap.lift (_ : QuotientMap ⇑π) e
          (_ :
            ∀ (a b : (forget Profinite).obj X),
              π a = π b → ((ContinuousMap.mk fun x => a) ≫ e) a = ((ContinuousMap.mk fun x => b) ≫ e) a))
      e (_ : ∀ {Z : Profinite} (g₁ g₂ : Z ⟶ X), g₁ ≫ π = g₂ ≫ π → g₁ ≫ e = g₂ ≫ e)

Next tactic:
assumption
/--
Implementation: If `π` is a surjective morphism in `Profinite`, then it is an effective epi.
The theorem `Profinite.effectiveEpi_tfae` should be used instead.
-/
noncomputable
def struct {B X : Profinite.{u}} (π : X ⟶ B) (hπ : Function.Surjective π) :
    EffectiveEpiStruct π where
  desc e h := (QuotientMap.of_surjective_continuous hπ π.continuous).lift e fun a b hab ↦
    FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; exact hab)) a
  fac e h := ((QuotientMap.of_surjective_continuous hπ π.continuous).lift_comp e
    fun a b hab ↦ FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; exact hab)) a)
  uniq e h g hm := by
    suffices g = (QuotientMap.of_surjective_continuous hπ π.continuous).liftEquiv ⟨e,
      fun a b hab ↦ FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
      (by ext; exact hab)) a⟩ by assumption
    

Proof state:
B X : Profinite
π : X ⟶ B
hπ : Function.Surjective ⇑π
W✝ : Profinite
e : X ⟶ W✝
h : ∀ {Z : Profinite} (g₁ g₂ : Z ⟶ X), g₁ ≫ π = g₂ ≫ π → g₁ ≫ e = g₂ ≫ e
g : B ⟶ W✝
hm : π ≫ g = e
⊢ g =
    (QuotientMap.liftEquiv (_ : QuotientMap ⇑π))
      { val := e,
        property :=
          (_ :
            ∀ (a b : (forget Profinite).obj X),
              π a = π b → ((ContinuousMap.mk fun x => a) ≫ e) a = ((ContinuousMap.mk fun x => b) ≫ e) a) }

Next tactic:
rw [← Equiv.symm_apply_eq (QuotientMap.of_surjective_continuous hπ π.continuous).liftEquiv]
/--
Implementation: If `π` is a surjective morphism in `Profinite`, then it is an effective epi.
The theorem `Profinite.effectiveEpi_tfae` should be used instead.
-/
noncomputable
def struct {B X : Profinite.{u}} (π : X ⟶ B) (hπ : Function.Surjective π) :
    EffectiveEpiStruct π where
  desc e h := (QuotientMap.of_surjective_continuous hπ π.continuous).lift e fun a b hab ↦
    FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; exact hab)) a
  fac e h := ((QuotientMap.of_surjective_continuous hπ π.continuous).lift_comp e
    fun a b hab ↦ FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; exact hab)) a)
  uniq e h g hm := by
    suffices g = (QuotientMap.of_surjective_continuous hπ π.continuous).liftEquiv ⟨e,
      fun a b hab ↦ FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
      (by ext; exact hab)) a⟩ by assumption
    rw [← Equiv.symm_apply_eq (QuotientMap.of_surjective_continuous hπ π.continuous).liftEquiv]
    

Proof state:
B X : Profinite
π : X ⟶ B
hπ : Function.Surjective ⇑π
W✝ : Profinite
e : X ⟶ W✝
h : ∀ {Z : Profinite} (g₁ g₂ : Z ⟶ X), g₁ ≫ π = g₂ ≫ π → g₁ ≫ e = g₂ ≫ e
g : B ⟶ W✝
hm : π ≫ g = e
⊢ (QuotientMap.liftEquiv (_ : QuotientMap ⇑π)).symm g =
    { val := e,
      property :=
        (_ :
          ∀ (a b : (forget Profinite).obj X),
            π a = π b → ((ContinuousMap.mk fun x => a) ≫ e) a = ((ContinuousMap.mk fun x => b) ≫ e) a) }

Next tactic:
ext
/--
Implementation: If `π` is a surjective morphism in `Profinite`, then it is an effective epi.
The theorem `Profinite.effectiveEpi_tfae` should be used instead.
-/
noncomputable
def struct {B X : Profinite.{u}} (π : X ⟶ B) (hπ : Function.Surjective π) :
    EffectiveEpiStruct π where
  desc e h := (QuotientMap.of_surjective_continuous hπ π.continuous).lift e fun a b hab ↦
    FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; exact hab)) a
  fac e h := ((QuotientMap.of_surjective_continuous hπ π.continuous).lift_comp e
    fun a b hab ↦ FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; exact hab)) a)
  uniq e h g hm := by
    suffices g = (QuotientMap.of_surjective_continuous hπ π.continuous).liftEquiv ⟨e,
      fun a b hab ↦ FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
      (by ext; exact hab)) a⟩ by assumption
    rw [← Equiv.symm_apply_eq (QuotientMap.of_surjective_continuous hπ π.continuous).liftEquiv]
    ext
    

Proof state:
case a.h
B X : Profinite
π : X ⟶ B
hπ : Function.Surjective ⇑π
W✝ : Profinite
e : X ⟶ W✝
h : ∀ {Z : Profinite} (g₁ g₂ : Z ⟶ X), g₁ ≫ π = g₂ ≫ π → g₁ ≫ e = g₂ ≫ e
g : B ⟶ W✝
hm : π ≫ g = e
a✝ : (forget Profinite).obj X
⊢ ↑((QuotientMap.liftEquiv (_ : QuotientMap ⇑π)).symm g) a✝ =
    ↑{ val := e,
          property :=
            (_ :
              ∀ (a b : (forget Profinite).obj X),
                π a = π b → ((ContinuousMap.mk fun x => a) ≫ e) a = ((ContinuousMap.mk fun x => b) ≫ e) a) }
      a✝

Next tactic:
simp only [QuotientMap.liftEquiv_symm_apply_coe, ContinuousMap.comp_apply, ← hm]
/--
Implementation: If `π` is a surjective morphism in `Profinite`, then it is an effective epi.
The theorem `Profinite.effectiveEpi_tfae` should be used instead.
-/
noncomputable
def struct {B X : Profinite.{u}} (π : X ⟶ B) (hπ : Function.Surjective π) :
    EffectiveEpiStruct π where
  desc e h := (QuotientMap.of_surjective_continuous hπ π.continuous).lift e fun a b hab ↦
    FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; exact hab)) a
  fac e h := ((QuotientMap.of_surjective_continuous hπ π.continuous).lift_comp e
    fun a b hab ↦ FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
    (by ext; exact hab)) a)
  uniq e h g hm := by
    suffices g = (QuotientMap.of_surjective_continuous hπ π.continuous).liftEquiv ⟨e,
      fun a b hab ↦ FunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
      (by ext; exact hab)) a⟩ by assumption
    rw [← Equiv.symm_apply_eq (QuotientMap.of_surjective_continuous hπ π.continuous).liftEquiv]
    ext
    simp only [QuotientMap.liftEquiv_symm_apply_coe, ContinuousMap.comp_apply, ← hm]
    

Proof state:
case a.h
B X : Profinite
π : X ⟶ B
hπ : Function.Surjective ⇑π
W✝ : Profinite
e : X ⟶ W✝
h : ∀ {Z : Profinite} (g₁ g₂ : Z ⟶ X), g₁ ≫ π = g₂ ≫ π → g₁ ≫ e = g₂ ≫ e
g : B ⟶ W✝
hm : π ≫ g = e
a✝ : (forget Profinite).obj X
⊢ g (π a✝) = (π ≫ g) a✝

Next tactic:
rfl
open List in
theorem effectiveEpi_tfae
    {B X : Profinite.{u}} (π : X ⟶ B) :
    TFAE
    [ EffectiveEpi π
    , Epi π
    , Function.Surjective π
    ] := by
  

Proof state:
B X : Profinite
π : X ⟶ B
⊢ TFAE [EffectiveEpi π, Epi π, Function.Surjective ⇑π]

Next tactic:
tfae_have 1 → 2
open List in
theorem effectiveEpi_tfae
    {B X : Profinite.{u}} (π : X ⟶ B) :
    TFAE
    [ EffectiveEpi π
    , Epi π
    , Function.Surjective π
    ] := by
  tfae_have 1 → 2
  · 

Proof state:
case tfae_1_to_2
B X : Profinite
π : X ⟶ B
⊢ EffectiveEpi π → Epi π

Next tactic:
intro
open List in
theorem effectiveEpi_tfae
    {B X : Profinite.{u}} (π : X ⟶ B) :
    TFAE
    [ EffectiveEpi π
    , Epi π
    , Function.Surjective π
    ] := by
  tfae_have 1 → 2
  · intro; 

Proof state:
case tfae_1_to_2
B X : Profinite
π : X ⟶ B
✝ : EffectiveEpi π
⊢ Epi π

Next tactic:
infer_instance
open List in
theorem effectiveEpi_tfae
    {B X : Profinite.{u}} (π : X ⟶ B) :
    TFAE
    [ EffectiveEpi π
    , Epi π
    , Function.Surjective π
    ] := by
  tfae_have 1 → 2
  · intro; infer_instance
  

Proof state:
B X : Profinite
π : X ⟶ B
tfae_1_to_2 : EffectiveEpi π → Epi π
⊢ TFAE [EffectiveEpi π, Epi π, Function.Surjective ⇑π]

Next tactic:
tfae_have 2 ↔ 3
open List in
theorem effectiveEpi_tfae
    {B X : Profinite.{u}} (π : X ⟶ B) :
    TFAE
    [ EffectiveEpi π
    , Epi π
    , Function.Surjective π
    ] := by
  tfae_have 1 → 2
  · intro; infer_instance
  tfae_have 2 ↔ 3
  · 

Proof state:
case tfae_2_iff_3
B X : Profinite
π : X ⟶ B
tfae_1_to_2 : EffectiveEpi π → Epi π
⊢ Epi π ↔ Function.Surjective ⇑π

Next tactic:
exact epi_iff_surjective π
open List in
theorem effectiveEpi_tfae
    {B X : Profinite.{u}} (π : X ⟶ B) :
    TFAE
    [ EffectiveEpi π
    , Epi π
    , Function.Surjective π
    ] := by
  tfae_have 1 → 2
  · intro; infer_instance
  tfae_have 2 ↔ 3
  · exact epi_iff_surjective π
  

Proof state:
B X : Profinite
π : X ⟶ B
tfae_1_to_2 : EffectiveEpi π → Epi π
tfae_2_iff_3 : Epi π ↔ Function.Surjective ⇑π
⊢ TFAE [EffectiveEpi π, Epi π, Function.Surjective ⇑π]

Next tactic:
tfae_have 3 → 1
open List in
theorem effectiveEpi_tfae
    {B X : Profinite.{u}} (π : X ⟶ B) :
    TFAE
    [ EffectiveEpi π
    , Epi π
    , Function.Surjective π
    ] := by
  tfae_have 1 → 2
  · intro; infer_instance
  tfae_have 2 ↔ 3
  · exact epi_iff_surjective π
  tfae_have 3 → 1
  · 

Proof state:
case tfae_3_to_1
B X : Profinite
π : X ⟶ B
tfae_1_to_2 : EffectiveEpi π → Epi π
tfae_2_iff_3 : Epi π ↔ Function.Surjective ⇑π
⊢ Function.Surjective ⇑π → EffectiveEpi π

Next tactic:
exact fun hπ ↦ ⟨⟨struct π hπ⟩⟩
open List in
theorem effectiveEpi_tfae
    {B X : Profinite.{u}} (π : X ⟶ B) :
    TFAE
    [ EffectiveEpi π
    , Epi π
    , Function.Surjective π
    ] := by
  tfae_have 1 → 2
  · intro; infer_instance
  tfae_have 2 ↔ 3
  · exact epi_iff_surjective π
  tfae_have 3 → 1
  · exact fun hπ ↦ ⟨⟨struct π hπ⟩⟩
  

Proof state:
B X : Profinite
π : X ⟶ B
tfae_1_to_2 : EffectiveEpi π → Epi π
tfae_2_iff_3 : Epi π ↔ Function.Surjective ⇑π
tfae_3_to_1 : Function.Surjective ⇑π → EffectiveEpi π
⊢ TFAE [EffectiveEpi π, Epi π, Function.Surjective ⇑π]

Next tactic:
tfae_finish
instance : Preregular Profinite where
  exists_fac := by
    

Proof state:
⊢ ∀ {X Y Z : Profinite} (f : X ⟶ Y) (g : Z ⟶ Y) [inst : EffectiveEpi g],
    ∃ W h, ∃ (_ : EffectiveEpi h), ∃ i, i ≫ g = h ≫ f

Next tactic:
intro X Y Z f π hπ
instance : Preregular Profinite where
  exists_fac := by
    intro X Y Z f π hπ
    

Proof state:
X Y Z : Profinite
f : X ⟶ Y
π : Z ⟶ Y
hπ : EffectiveEpi π
⊢ ∃ W h, ∃ (_ : EffectiveEpi h), ∃ i, i ≫ π = h ≫ f

Next tactic:
refine ⟨pullback f π, pullback.fst f π, ?_, pullback.snd f π, (pullback.condition _ _).symm⟩
instance : Preregular Profinite where
  exists_fac := by
    intro X Y Z f π hπ
    refine ⟨pullback f π, pullback.fst f π, ?_, pullback.snd f π, (pullback.condition _ _).symm⟩
    

Proof state:
X Y Z : Profinite
f : X ⟶ Y
π : Z ⟶ Y
hπ : EffectiveEpi π
⊢ EffectiveEpi (pullback.fst f π)

Next tactic:
have := fun X Y (f : X ⟶ Y) ↦ (effectiveEpi_tfae f).out 0 2