Theorem: AddCommGroupCat.injective_as_module_of_injective_as_Ab
File: Mathlib/Algebra/Category/GroupCat/Injective.lean

tactic: let G : (⟨X,inferInstance⟩ : AddCommGroupCat) ⟶ ⟨A,inferInstance⟩ :=
  @LinearMap.toAddMonoidHom _ _ _ _ _ _ _ _ (_) _ _ g
state_before: A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
⊢ ∃ h, f ≫ h = g

tactic: let F : (⟨X,inferInstance⟩ : AddCommGroupCat) ⟶ ⟨Y,inferInstance⟩ :=
  @LinearMap.toAddMonoidHom _ _ _ _ _ _ _ _ (_) (_) _ f
state_before: A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
⊢ ∃ h, f ≫ h = g

tactic: have : Mono F := by
  rw [mono_iff_injective]
  intro _ _ h
  exact ((ModuleCat.mono_iff_injective f).mp m) h
state_before: A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
⊢ ∃ h, f ≫ h = g

tactic: refine ⟨ @LinearMap.mk _ _ _ _ _ _ _ _ _ (_) _ (Injective.factorThru G F).toAddHom ?_ , ?_⟩
state_before: A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
⊢ ∃ h, f ≫ h = g

tactic: change ∀ r, ∀ x, (Injective.factorThru G F).toFun _ = _ • (Injective.factorThru G F).toFun _
state_before: case refine_1
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
⊢ ∀ (r : ℤ) (x : ↑Y),
    AddHom.toFun (↑(Injective.factorThru G F)) (r • x) =
      ↑(RingHom.id ℤ) r • AddHom.toFun (↑(Injective.factorThru G F)) x

case refine_2
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
⊢ f ≫ { toAddHom := ↑(Injective.factorThru G F), map_smul' := ?refine_1 } = g

tactic: ext x
state_before: case refine_2
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
⊢ f ≫
      { toAddHom := ↑(Injective.factorThru G F),
        map_smul' :=
          (_ :
            ∀ (r : ℤ) (x : ↑Y),
              ZeroHom.toFun (↑(Injective.factorThru G F)) (r • x) =
                ↑(RingHom.id ℤ) r • ZeroHom.toFun (↑(Injective.factorThru G F)) x) } =
    g

tactic: have := congrFun (congrArg (fun H => H.toFun) (Injective.comp_factorThru G F)) x
state_before: case refine_2.h
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
x : ↑X
⊢ ↑(f ≫
          { toAddHom := ↑(Injective.factorThru G F),
            map_smul' :=
              (_ :
                ∀ (r : ℤ) (x : ↑Y),
                  ZeroHom.toFun (↑(Injective.factorThru G F)) (r • x) =
                    ↑(RingHom.id ℤ) r • ZeroHom.toFun (↑(Injective.factorThru G F)) x) })
      x =
    ↑g x

tactic: simp only [ModuleCat.coe_comp, Function.comp_apply] at this
state_before: case refine_2.h
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this✝ : Mono F
x : ↑X
this : (fun H => H.toFun) (F ≫ Injective.factorThru G F) x = (fun H => H.toFun) G x
⊢ ↑(f ≫
          { toAddHom := ↑(Injective.factorThru G F),
            map_smul' :=
              (_ :
                ∀ (r : ℤ) (x : ↑Y),
                  ZeroHom.toFun (↑(Injective.factorThru G F)) (r • x) =
                    ↑(RingHom.id ℤ) r • ZeroHom.toFun (↑(Injective.factorThru G F)) x) })
      x =
    ↑g x

tactic: apply this
state_before: case refine_2.h
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this✝ : Mono F
x : ↑X
this :
  ZeroHom.toFun
      (↑(LinearMap.toAddMonoidHom f ≫ Injective.factorThru (LinearMap.toAddMonoidHom g) (LinearMap.toAddMonoidHom f)))
      x =
    ZeroHom.toFun (↑(LinearMap.toAddMonoidHom g)) x
⊢ ↑(f ≫
          { toAddHom := ↑(Injective.factorThru G F),
            map_smul' :=
              (_ :
                ∀ (r : ℤ) (x : ↑Y),
                  ZeroHom.toFun (↑(Injective.factorThru G F)) (r • x) =
                    ↑(RingHom.id ℤ) r • ZeroHom.toFun (↑(Injective.factorThru G F)) x) })
      x =
    ↑g x

tactic: rw [mono_iff_injective]
state_before: A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
⊢ Mono F

tactic: intro _ _ h
state_before: A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
⊢ Function.Injective ↑F

tactic: exact ((ModuleCat.mono_iff_injective f).mp m) h
state_before: A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
a₁✝ a₂✝ : ↑(Bundled.mk ↑X)
h : ↑F a₁✝ = ↑F a₂✝
⊢ a₁✝ = a₂✝

tactic: intro m x
state_before: case refine_1
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
⊢ ∀ (r : ℤ) (x : ↑Y),
    ZeroHom.toFun (↑(Injective.factorThru G F)) (r • x) =
      ↑(RingHom.id ℤ) r • ZeroHom.toFun (↑(Injective.factorThru G F)) x

tactic: rw [AddMonoidHom.toFun_eq_coe, RingHom.id_apply]
state_before: case refine_1
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m✝ : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
m : ℤ
x : ↑Y
⊢ ZeroHom.toFun (↑(Injective.factorThru G F)) (m • x) =
    ↑(RingHom.id ℤ) m • ZeroHom.toFun (↑(Injective.factorThru G F)) x

tactic: induction' m using Int.induction_on with n hn n hn
state_before: case refine_1
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m✝ : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
m : ℤ
x : ↑Y
⊢ ↑(Injective.factorThru G F) (m • x) = m • ↑(Injective.factorThru G F) x

tactic: rw [zero_smul]
state_before: case refine_1.hz
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
x : ↑Y
⊢ ↑(Injective.factorThru G F) (0 • x) = 0 • ↑(Injective.factorThru G F) x

tactic: convert map_zero (M := Y) (N := A) (F := Y →+ A) _
state_before: case refine_1.hz
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
x : ↑Y
⊢ ↑(Injective.factorThru G F) (0 • x) = 0

tactic: refine @zero_smul ℤ Y (MonoidWithZero.toZero) (AddMonoid.toZero) ?_ x
state_before: case h.e'_2.h.e'_6
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
x : ↑Y
⊢ 0 • x = 0

tactic: conv_rhs => rw [add_smul]
state_before: case refine_1.hp
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
x : ↑Y
n : ℕ
hn : ↑(Injective.factorThru G F) (↑n • x) = ↑n • ↑(Injective.factorThru G F) x
⊢ ↑(Injective.factorThru G F) ((↑n + 1) • x) = (↑n + 1) • ↑(Injective.factorThru G F) x

tactic: rw [← hn, one_smul, ←map_add]
state_before: case refine_1.hp
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
x : ↑Y
n : ℕ
hn : ↑(Injective.factorThru G F) (↑n • x) = ↑n • ↑(Injective.factorThru G F) x
⊢ ↑(Injective.factorThru G F) ((↑n + 1) • x) = ↑n • ↑(Injective.factorThru G F) x + 1 • ↑(Injective.factorThru G F) x

tactic: congr
state_before: case refine_1.hp
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
x : ↑Y
n : ℕ
hn : ↑(Injective.factorThru G F) (↑n • x) = ↑n • ↑(Injective.factorThru G F) x
⊢ ↑(Injective.factorThru G F) ((↑n + 1) • x) = ↑(Injective.factorThru G F) (↑n • x + x)

tactic: convert @add_smul ℤ Y _ _ ?_ n 1 x
state_before: case refine_1.hp.h.e_6.h
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
x : ↑Y
n : ℕ
hn : ↑(Injective.factorThru G F) (↑n • x) = ↑n • ↑(Injective.factorThru G F) x
⊢ (↑n + 1) • x = ↑n • x + x

tactic: refine @one_smul ℤ Y _ ?_ x|>.symm
state_before: case h.e'_3.h.e'_6
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
x : ↑Y
n : ℕ
hn : ↑(Injective.factorThru G F) (↑n • x) = ↑n • ↑(Injective.factorThru G F) x
⊢ x = 1 • x

tactic: conv_rhs => rw [sub_smul]
state_before: case refine_1.hn
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
x : ↑Y
n : ℕ
hn : ↑(Injective.factorThru G F) (-↑n • x) = -↑n • ↑(Injective.factorThru G F) x
⊢ ↑(Injective.factorThru G F) ((-↑n - 1) • x) = (-↑n - 1) • ↑(Injective.factorThru G F) x

tactic: rw [← hn, one_smul, ←map_sub]
state_before: case refine_1.hn
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
x : ↑Y
n : ℕ
hn : ↑(Injective.factorThru G F) (-↑n • x) = -↑n • ↑(Injective.factorThru G F) x
⊢ ↑(Injective.factorThru G F) ((-↑n - 1) • x) = -↑n • ↑(Injective.factorThru G F) x - 1 • ↑(Injective.factorThru G F) x

tactic: congr
state_before: case refine_1.hn
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
x : ↑Y
n : ℕ
hn : ↑(Injective.factorThru G F) (-↑n • x) = -↑n • ↑(Injective.factorThru G F) x
⊢ ↑(Injective.factorThru G F) ((-↑n - 1) • x) = ↑(Injective.factorThru G F) (-↑n • x - x)

tactic: convert @sub_smul ℤ Y _ _ ?_ (-n) 1 x
state_before: case refine_1.hn.h.e_6.h
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
x : ↑Y
n : ℕ
hn : ↑(Injective.factorThru G F) (-↑n • x) = -↑n • ↑(Injective.factorThru G F) x
⊢ (-↑n - 1) • x = -↑n • x - x

tactic: refine @one_smul ℤ Y _ ?_ x|>.symm
state_before: case h.e'_3.h.e'_6
A : Type u
inst✝¹ : AddCommGroup A
inst✝ : Injective (Bundled.mk A)
X Y : ModuleCat ℤ
g : X ⟶ ModuleCat.mk A
f : X ⟶ Y
m : Mono f
G : Bundled.mk ↑X ⟶ Bundled.mk A := LinearMap.toAddMonoidHom g
F : Bundled.mk ↑X ⟶ Bundled.mk ↑Y := LinearMap.toAddMonoidHom f
this : Mono F
x : ↑Y
n : ℕ
hn : ↑(Injective.factorThru G F) (-↑n • x) = -↑n • ↑(Injective.factorThru G F) x
⊢ x = 1 • x