l3lab/ntp-mathlib huggingface dataset:
instance [SeminormedRing A] : NormedRing (Completion A) :=
  { Completion.ring,
    Completion.instMetricSpace with
    dist_eq := fun x y => by
      refine Completion.induction_on₂ x y ?_ ?_ <;> clear x y
      · refine' isClosed_eq (Completion.uniformContinuous_extension₂ _).continuous _
        exact Continuous.comp Completion.continuous_extension continuous_sub
      · intro x y
        rw [← Completion.coe_sub, norm_coe, Completion.dist_eq, dist_eq_norm]
    norm_mul := fun x y => by
      refine Completion.induction_on₂ x y ?_ ?_ <;> clear x y
      · exact
          isClosed_le (Continuous.comp continuous_norm continuous_mul)
            (Continuous.comp _root_.continuous_mul
              (Continuous.prod_map continuous_norm continuous_norm))
      · intro x y
        simp only [← coe_mul, norm_coe]
        

Proof state:
case refine_2
𝕜 : Type u_1
E : Type u_2
inst✝³ : NormedField 𝕜
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace 𝕜 E
A : Type u_3
inst✝ : SeminormedRing A
src✝¹ : Ring (Completion A) := ring
src✝ : MetricSpace (Completion A) := instMetricSpace
x y : A
⊢ ‖x * y‖ ≤ ‖x‖ * ‖y‖

Next tactic:
exact norm_mul_le x y
instance [SeminormedCommRing A] [NormedAlgebra 𝕜 A] [UniformContinuousConstSMul 𝕜 A] :
    NormedAlgebra 𝕜 (Completion A) :=
  { Completion.algebra A 𝕜 with
    norm_smul_le := fun r x => by
      

Proof state:
𝕜 : Type u_1
E : Type u_2
inst✝⁵ : NormedField 𝕜
inst✝⁴ : NormedAddCommGroup E
inst✝³ : NormedSpace 𝕜 E
A : Type u_3
inst✝² : SeminormedCommRing A
inst✝¹ : NormedAlgebra 𝕜 A
inst✝ : UniformContinuousConstSMul 𝕜 A
src✝ : Algebra 𝕜 (Completion A) := algebra A 𝕜
r : 𝕜
x : Completion A
⊢ ‖r • x‖ ≤ ‖r‖ * ‖x‖

Next tactic:
refine Completion.induction_on x ?_ ?_
instance [SeminormedCommRing A] [NormedAlgebra 𝕜 A] [UniformContinuousConstSMul 𝕜 A] :
    NormedAlgebra 𝕜 (Completion A) :=
  { Completion.algebra A 𝕜 with
    norm_smul_le := fun r x => by
      refine Completion.induction_on x ?_ ?_ <;> 

Proof state:
case refine_1
𝕜 : Type u_1
E : Type u_2
inst✝⁵ : NormedField 𝕜
inst✝⁴ : NormedAddCommGroup E
inst✝³ : NormedSpace 𝕜 E
A : Type u_3
inst✝² : SeminormedCommRing A
inst✝¹ : NormedAlgebra 𝕜 A
inst✝ : UniformContinuousConstSMul 𝕜 A
src✝ : Algebra 𝕜 (Completion A) := algebra A 𝕜
r : 𝕜
x : Completion A
⊢ IsClosed {a | ‖r • a‖ ≤ ‖r‖ * ‖a‖}

Next tactic:
clear x
instance [SeminormedCommRing A] [NormedAlgebra 𝕜 A] [UniformContinuousConstSMul 𝕜 A] :
    NormedAlgebra 𝕜 (Completion A) :=
  { Completion.algebra A 𝕜 with
    norm_smul_le := fun r x => by
      refine Completion.induction_on x ?_ ?_ <;> 

Proof state:
case refine_2
𝕜 : Type u_1
E : Type u_2
inst✝⁵ : NormedField 𝕜
inst✝⁴ : NormedAddCommGroup E
inst✝³ : NormedSpace 𝕜 E
A : Type u_3
inst✝² : SeminormedCommRing A
inst✝¹ : NormedAlgebra 𝕜 A
inst✝ : UniformContinuousConstSMul 𝕜 A
src✝ : Algebra 𝕜 (Completion A) := algebra A 𝕜
r : 𝕜
x : Completion A
⊢ ∀ (a : A), ‖r • ↑A a‖ ≤ ‖r‖ * ‖↑A a‖

Next tactic:
clear x
instance [SeminormedCommRing A] [NormedAlgebra 𝕜 A] [UniformContinuousConstSMul 𝕜 A] :
    NormedAlgebra 𝕜 (Completion A) :=
  { Completion.algebra A 𝕜 with
    norm_smul_le := fun r x => by
      refine Completion.induction_on x ?_ ?_ <;> clear x
      · 

Proof state:
case refine_1
𝕜 : Type u_1
E : Type u_2
inst✝⁵ : NormedField 𝕜
inst✝⁴ : NormedAddCommGroup E
inst✝³ : NormedSpace 𝕜 E
A : Type u_3
inst✝² : SeminormedCommRing A
inst✝¹ : NormedAlgebra 𝕜 A
inst✝ : UniformContinuousConstSMul 𝕜 A
src✝ : Algebra 𝕜 (Completion A) := algebra A 𝕜
r : 𝕜
⊢ IsClosed {a | ‖r • a‖ ≤ ‖r‖ * ‖a‖}

Next tactic:
exact
          isClosed_le (Continuous.comp continuous_norm (continuous_const_smul r))
            (Continuous.comp (continuous_mul_left _) continuous_norm)
instance [SeminormedCommRing A] [NormedAlgebra 𝕜 A] [UniformContinuousConstSMul 𝕜 A] :
    NormedAlgebra 𝕜 (Completion A) :=
  { Completion.algebra A 𝕜 with
    norm_smul_le := fun r x => by
      refine Completion.induction_on x ?_ ?_ <;> clear x
      · exact
          isClosed_le (Continuous.comp continuous_norm (continuous_const_smul r))
            (Continuous.comp (continuous_mul_left _) continuous_norm)
      · 

Proof state:
case refine_2
𝕜 : Type u_1
E : Type u_2
inst✝⁵ : NormedField 𝕜
inst✝⁴ : NormedAddCommGroup E
inst✝³ : NormedSpace 𝕜 E
A : Type u_3
inst✝² : SeminormedCommRing A
inst✝¹ : NormedAlgebra 𝕜 A
inst✝ : UniformContinuousConstSMul 𝕜 A
src✝ : Algebra 𝕜 (Completion A) := algebra A 𝕜
r : 𝕜
⊢ ∀ (a : A), ‖r • ↑A a‖ ≤ ‖r‖ * ‖↑A a‖

Next tactic:
intro x
instance [SeminormedCommRing A] [NormedAlgebra 𝕜 A] [UniformContinuousConstSMul 𝕜 A] :
    NormedAlgebra 𝕜 (Completion A) :=
  { Completion.algebra A 𝕜 with
    norm_smul_le := fun r x => by
      refine Completion.induction_on x ?_ ?_ <;> clear x
      · exact
          isClosed_le (Continuous.comp continuous_norm (continuous_const_smul r))
            (Continuous.comp (continuous_mul_left _) continuous_norm)
      · intro x
        

Proof state:
case refine_2
𝕜 : Type u_1
E : Type u_2
inst✝⁵ : NormedField 𝕜
inst✝⁴ : NormedAddCommGroup E
inst✝³ : NormedSpace 𝕜 E
A : Type u_3
inst✝² : SeminormedCommRing A
inst✝¹ : NormedAlgebra 𝕜 A
inst✝ : UniformContinuousConstSMul 𝕜 A
src✝ : Algebra 𝕜 (Completion A) := algebra A 𝕜
r : 𝕜
x : A
⊢ ‖r • ↑A x‖ ≤ ‖r‖ * ‖↑A x‖

Next tactic:
simp only [← coe_smul, norm_coe]
instance [SeminormedCommRing A] [NormedAlgebra 𝕜 A] [UniformContinuousConstSMul 𝕜 A] :
    NormedAlgebra 𝕜 (Completion A) :=
  { Completion.algebra A 𝕜 with
    norm_smul_le := fun r x => by
      refine Completion.induction_on x ?_ ?_ <;> clear x
      · exact
          isClosed_le (Continuous.comp continuous_norm (continuous_const_smul r))
            (Continuous.comp (continuous_mul_left _) continuous_norm)
      · intro x
        simp only [← coe_smul, norm_coe]
        

Proof state:
case refine_2
𝕜 : Type u_1
E : Type u_2
inst✝⁵ : NormedField 𝕜
inst✝⁴ : NormedAddCommGroup E
inst✝³ : NormedSpace 𝕜 E
A : Type u_3
inst✝² : SeminormedCommRing A
inst✝¹ : NormedAlgebra 𝕜 A
inst✝ : UniformContinuousConstSMul 𝕜 A
src✝ : Algebra 𝕜 (Completion A) := algebra A 𝕜
r : 𝕜
x : A
⊢ ‖r • x‖ ≤ ‖r‖ * ‖x‖

Next tactic:
exact norm_smul_le r x
/-- The universal property for the image factorisation -/
noncomputable def image.lift (F' : MonoFactorisation f) : image f ⟶ F'.I where
  toFun := (fun x => F'.e (Classical.indefiniteDescription _ x.2).1 : image f → F'.I)
  map_add' x y := by
    

Proof state:
R : Type u
inst✝ : Ring R
G H : ModuleCat R
f : G ⟶ H
F' : MonoFactorisation f
x y : ↑(image f)
⊢ (fun x => F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f))) (x + y) =
    (fun x => F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f))) x +
      (fun x => F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f))) y

Next tactic:
apply (mono_iff_injective F'.m).1
/-- The universal property for the image factorisation -/
noncomputable def image.lift (F' : MonoFactorisation f) : image f ⟶ F'.I where
  toFun := (fun x => F'.e (Classical.indefiniteDescription _ x.2).1 : image f → F'.I)
  map_add' x y := by
    apply (mono_iff_injective F'.m).1; 

Proof state:
case a
R : Type u
inst✝ : Ring R
G H : ModuleCat R
f : G ⟶ H
F' : MonoFactorisation f
x y : ↑(image f)
⊢ Mono F'.m
case a
R : Type u
inst✝ : Ring R
G H : ModuleCat R
f : G ⟶ H
F' : MonoFactorisation f
x y : ↑(image f)
⊢ F'.m
      ((fun x => F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
        (x + y)) =
    F'.m
      ((fun x => F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f))) x +
        (fun x => F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f))) y)

Next tactic:
infer_instance
/-- The universal property for the image factorisation -/
noncomputable def image.lift (F' : MonoFactorisation f) : image f ⟶ F'.I where
  toFun := (fun x => F'.e (Classical.indefiniteDescription _ x.2).1 : image f → F'.I)
  map_add' x y := by
    apply (mono_iff_injective F'.m).1; infer_instance
    

Proof state:
case a
R : Type u
inst✝ : Ring R
G H : ModuleCat R
f : G ⟶ H
F' : MonoFactorisation f
x y : ↑(image f)
⊢ F'.m
      ((fun x => F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
        (x + y)) =
    F'.m
      ((fun x => F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f))) x +
        (fun x => F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f))) y)

Next tactic:
rw [LinearMap.map_add]
/-- The universal property for the image factorisation -/
noncomputable def image.lift (F' : MonoFactorisation f) : image f ⟶ F'.I where
  toFun := (fun x => F'.e (Classical.indefiniteDescription _ x.2).1 : image f → F'.I)
  map_add' x y := by
    apply (mono_iff_injective F'.m).1; infer_instance
    rw [LinearMap.map_add]
    

Proof state:
case a
R : Type u
inst✝ : Ring R
G H : ModuleCat R
f : G ⟶ H
F' : MonoFactorisation f
x y : ↑(image f)
⊢ F'.m
      ((fun x => F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
        (x + y)) =
    F'.m ((fun x => F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f))) x) +
      F'.m ((fun x => F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f))) y)

Next tactic:
change (F'.e ≫ F'.m) _ = (F'.e ≫ F'.m) _ + (F'.e ≫ F'.m) _
/-- The universal property for the image factorisation -/
noncomputable def image.lift (F' : MonoFactorisation f) : image f ⟶ F'.I where
  toFun := (fun x => F'.e (Classical.indefiniteDescription _ x.2).1 : image f → F'.I)
  map_add' x y := by
    apply (mono_iff_injective F'.m).1; infer_instance
    rw [LinearMap.map_add]
    change (F'.e ≫ F'.m) _ = (F'.e ≫ F'.m) _ + (F'.e ≫ F'.m) _
    

Proof state:
case a
R : Type u
inst✝ : Ring R
G H : ModuleCat R
f : G ⟶ H
F' : MonoFactorisation f
x y : ↑(image f)
⊢ (F'.e ≫ F'.m) ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑(x + y)) (_ : ↑(x + y) ∈ LinearMap.range f)) =
    (F'.e ≫ F'.m) ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)) +
      (F'.e ≫ F'.m) ↑(Classical.indefiniteDescription (fun x => f x = ↑y) (_ : ↑y ∈ LinearMap.range f))

Next tactic:
simp_rw [F'.fac, (Classical.indefiniteDescription (fun z => f z = _) _).2]
/-- The universal property for the image factorisation -/
noncomputable def image.lift (F' : MonoFactorisation f) : image f ⟶ F'.I where
  toFun := (fun x => F'.e (Classical.indefiniteDescription _ x.2).1 : image f → F'.I)
  map_add' x y := by
    apply (mono_iff_injective F'.m).1; infer_instance
    rw [LinearMap.map_add]
    change (F'.e ≫ F'.m) _ = (F'.e ≫ F'.m) _ + (F'.e ≫ F'.m) _
    simp_rw [F'.fac, (Classical.indefiniteDescription (fun z => f z = _) _).2]
    

Proof state:
case a
R : Type u
inst✝ : Ring R
G H : ModuleCat R
f : G ⟶ H
F' : MonoFactorisation f
x y : ↑(image f)
⊢ ↑(x + y) = ↑x + ↑y

Next tactic:
rfl
/-- The universal property for the image factorisation -/
noncomputable def image.lift (F' : MonoFactorisation f) : image f ⟶ F'.I where
  toFun := (fun x => F'.e (Classical.indefiniteDescription _ x.2).1 : image f → F'.I)
  map_add' x y := by
    apply (mono_iff_injective F'.m).1; infer_instance
    rw [LinearMap.map_add]
    change (F'.e ≫ F'.m) _ = (F'.e ≫ F'.m) _ + (F'.e ≫ F'.m) _
    simp_rw [F'.fac, (Classical.indefiniteDescription (fun z => f z = _) _).2]
    rfl
  map_smul' c x := by
    

Proof state:
R : Type u
inst✝ : Ring R
G H : ModuleCat R
f : G ⟶ H
F' : MonoFactorisation f
c : R
x : ↑(image f)
⊢ AddHom.toFun
      { toFun := fun x => F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)),
        map_add' :=
          (_ :
            ∀ (x y : ↑(image f)),
              (fun x => F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                  (x + y) =
                (fun x => F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                    x +
                  (fun x =>
                      F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                    y) }
      (c • x) =
    (RingHom.id R) c •
      AddHom.toFun
        {
          toFun := fun x =>
            F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)),
          map_add' :=
            (_ :
              ∀ (x y : ↑(image f)),
                (fun x => F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                    (x + y) =
                  (fun x =>
                        F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                      x +
                    (fun x =>
                        F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                      y) }
        x

Next tactic:
apply (mono_iff_injective F'.m).1
/-- The universal property for the image factorisation -/
noncomputable def image.lift (F' : MonoFactorisation f) : image f ⟶ F'.I where
  toFun := (fun x => F'.e (Classical.indefiniteDescription _ x.2).1 : image f → F'.I)
  map_add' x y := by
    apply (mono_iff_injective F'.m).1; infer_instance
    rw [LinearMap.map_add]
    change (F'.e ≫ F'.m) _ = (F'.e ≫ F'.m) _ + (F'.e ≫ F'.m) _
    simp_rw [F'.fac, (Classical.indefiniteDescription (fun z => f z = _) _).2]
    rfl
  map_smul' c x := by
    apply (mono_iff_injective F'.m).1; 

Proof state:
case a
R : Type u
inst✝ : Ring R
G H : ModuleCat R
f : G ⟶ H
F' : MonoFactorisation f
c : R
x : ↑(image f)
⊢ Mono F'.m
case a
R : Type u
inst✝ : Ring R
G H : ModuleCat R
f : G ⟶ H
F' : MonoFactorisation f
c : R
x : ↑(image f)
⊢ F'.m
      (AddHom.toFun
        {
          toFun := fun x =>
            F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)),
          map_add' :=
            (_ :
              ∀ (x y : ↑(image f)),
                (fun x => F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                    (x + y) =
                  (fun x =>
                        F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                      x +
                    (fun x =>
                        F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                      y) }
        (c • x)) =
    F'.m
      ((RingHom.id R) c •
        AddHom.toFun
          {
            toFun := fun x =>
              F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)),
            map_add' :=
              (_ :
                ∀ (x y : ↑(image f)),
                  (fun x =>
                        F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                      (x + y) =
                    (fun x =>
                          F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                        x +
                      (fun x =>
                          F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                        y) }
          x)

Next tactic:
infer_instance
/-- The universal property for the image factorisation -/
noncomputable def image.lift (F' : MonoFactorisation f) : image f ⟶ F'.I where
  toFun := (fun x => F'.e (Classical.indefiniteDescription _ x.2).1 : image f → F'.I)
  map_add' x y := by
    apply (mono_iff_injective F'.m).1; infer_instance
    rw [LinearMap.map_add]
    change (F'.e ≫ F'.m) _ = (F'.e ≫ F'.m) _ + (F'.e ≫ F'.m) _
    simp_rw [F'.fac, (Classical.indefiniteDescription (fun z => f z = _) _).2]
    rfl
  map_smul' c x := by
    apply (mono_iff_injective F'.m).1; infer_instance
    

Proof state:
case a
R : Type u
inst✝ : Ring R
G H : ModuleCat R
f : G ⟶ H
F' : MonoFactorisation f
c : R
x : ↑(image f)
⊢ F'.m
      (AddHom.toFun
        {
          toFun := fun x =>
            F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)),
          map_add' :=
            (_ :
              ∀ (x y : ↑(image f)),
                (fun x => F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                    (x + y) =
                  (fun x =>
                        F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                      x +
                    (fun x =>
                        F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                      y) }
        (c • x)) =
    F'.m
      ((RingHom.id R) c •
        AddHom.toFun
          {
            toFun := fun x =>
              F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)),
            map_add' :=
              (_ :
                ∀ (x y : ↑(image f)),
                  (fun x =>
                        F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                      (x + y) =
                    (fun x =>
                          F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                        x +
                      (fun x =>
                          F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                        y) }
          x)

Next tactic:
rw [LinearMap.map_smul]
/-- The universal property for the image factorisation -/
noncomputable def image.lift (F' : MonoFactorisation f) : image f ⟶ F'.I where
  toFun := (fun x => F'.e (Classical.indefiniteDescription _ x.2).1 : image f → F'.I)
  map_add' x y := by
    apply (mono_iff_injective F'.m).1; infer_instance
    rw [LinearMap.map_add]
    change (F'.e ≫ F'.m) _ = (F'.e ≫ F'.m) _ + (F'.e ≫ F'.m) _
    simp_rw [F'.fac, (Classical.indefiniteDescription (fun z => f z = _) _).2]
    rfl
  map_smul' c x := by
    apply (mono_iff_injective F'.m).1; infer_instance
    rw [LinearMap.map_smul]
    

Proof state:
case a
R : Type u
inst✝ : Ring R
G H : ModuleCat R
f : G ⟶ H
F' : MonoFactorisation f
c : R
x : ↑(image f)
⊢ F'.m
      (AddHom.toFun
        {
          toFun := fun x =>
            F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)),
          map_add' :=
            (_ :
              ∀ (x y : ↑(image f)),
                (fun x => F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                    (x + y) =
                  (fun x =>
                        F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                      x +
                    (fun x =>
                        F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                      y) }
        (c • x)) =
    (RingHom.id R) c •
      F'.m
        (AddHom.toFun
          {
            toFun := fun x =>
              F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)),
            map_add' :=
              (_ :
                ∀ (x y : ↑(image f)),
                  (fun x =>
                        F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                      (x + y) =
                    (fun x =>
                          F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                        x +
                      (fun x =>
                          F'.e ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)))
                        y) }
          x)

Next tactic:
change (F'.e ≫ F'.m) _ = _ • (F'.e ≫ F'.m) _
/-- The universal property for the image factorisation -/
noncomputable def image.lift (F' : MonoFactorisation f) : image f ⟶ F'.I where
  toFun := (fun x => F'.e (Classical.indefiniteDescription _ x.2).1 : image f → F'.I)
  map_add' x y := by
    apply (mono_iff_injective F'.m).1; infer_instance
    rw [LinearMap.map_add]
    change (F'.e ≫ F'.m) _ = (F'.e ≫ F'.m) _ + (F'.e ≫ F'.m) _
    simp_rw [F'.fac, (Classical.indefiniteDescription (fun z => f z = _) _).2]
    rfl
  map_smul' c x := by
    apply (mono_iff_injective F'.m).1; infer_instance
    rw [LinearMap.map_smul]
    change (F'.e ≫ F'.m) _ = _ • (F'.e ≫ F'.m) _
    

Proof state:
case a
R : Type u
inst✝ : Ring R
G H : ModuleCat R
f : G ⟶ H
F' : MonoFactorisation f
c : R
x : ↑(image f)
⊢ (F'.e ≫ F'.m) ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑(c • x)) (_ : ↑(c • x) ∈ LinearMap.range f)) =
    (RingHom.id R) c •
      (F'.e ≫ F'.m) ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f))

Next tactic:
simp_rw [F'.fac, (Classical.indefiniteDescription (fun z => f z = _) _).2]
/-- The universal property for the image factorisation -/
noncomputable def image.lift (F' : MonoFactorisation f) : image f ⟶ F'.I where
  toFun := (fun x => F'.e (Classical.indefiniteDescription _ x.2).1 : image f → F'.I)
  map_add' x y := by
    apply (mono_iff_injective F'.m).1; infer_instance
    rw [LinearMap.map_add]
    change (F'.e ≫ F'.m) _ = (F'.e ≫ F'.m) _ + (F'.e ≫ F'.m) _
    simp_rw [F'.fac, (Classical.indefiniteDescription (fun z => f z = _) _).2]
    rfl
  map_smul' c x := by
    apply (mono_iff_injective F'.m).1; infer_instance
    rw [LinearMap.map_smul]
    change (F'.e ≫ F'.m) _ = _ • (F'.e ≫ F'.m) _
    simp_rw [F'.fac, (Classical.indefiniteDescription (fun z => f z = _) _).2]
    

Proof state:
case a
R : Type u
inst✝ : Ring R
G H : ModuleCat R
f : G ⟶ H
F' : MonoFactorisation f
c : R
x : ↑(image f)
⊢ ↑(c • x) = (RingHom.id R) c • ↑x

Next tactic:
rfl
theorem image.lift_fac (F' : MonoFactorisation f) : image.lift F' ≫ F'.m = image.ι f := by
  

Proof state:
R : Type u
inst✝ : Ring R
G H : ModuleCat R
f : G ⟶ H
F' : MonoFactorisation f
⊢ lift F' ≫ F'.m = ι f

Next tactic:
ext x
theorem image.lift_fac (F' : MonoFactorisation f) : image.lift F' ≫ F'.m = image.ι f := by
  ext x
  

Proof state:
case h
R : Type u
inst✝ : Ring R
G H : ModuleCat R
f : G ⟶ H
F' : MonoFactorisation f
x : ↑(image f)
⊢ (lift F' ≫ F'.m) x = (ι f) x

Next tactic:
change (F'.e ≫ F'.m) _ = _
theorem image.lift_fac (F' : MonoFactorisation f) : image.lift F' ≫ F'.m = image.ι f := by
  ext x
  change (F'.e ≫ F'.m) _ = _
  

Proof state:
case h
R : Type u
inst✝ : Ring R
G H : ModuleCat R
f : G ⟶ H
F' : MonoFactorisation f
x : ↑(image f)
⊢ (F'.e ≫ F'.m) ↑(Classical.indefiniteDescription (fun x_1 => f x_1 = ↑x) (_ : ↑x ∈ LinearMap.range f)) = (ι f) x

Next tactic:
rw [F'.fac, (Classical.indefiniteDescription _ x.2).2]
theorem image.lift_fac (F' : MonoFactorisation f) : image.lift F' ≫ F'.m = image.ι f := by
  ext x
  change (F'.e ≫ F'.m) _ = _
  rw [F'.fac, (Classical.indefiniteDescription _ x.2).2]
  

Proof state:
case h
R : Type u
inst✝ : Ring R
G H : ModuleCat R
f : G ⟶ H
F' : MonoFactorisation f
x : ↑(image f)
⊢ ↑x = (ι f) x

Next tactic:
rfl
@[simp, reassoc, elementwise]
theorem imageIsoRange_hom_subtype {G H : ModuleCat.{v} R} (f : G ⟶ H) :
    (imageIsoRange f).hom ≫ ModuleCat.ofHom f.range.subtype = Limits.image.ι f := by
  

Proof state:
R : Type u
inst✝ : Ring R
G✝ H✝ : ModuleCat R
f✝ : G✝ ⟶ H✝
G H : ModuleCat R
f : G ⟶ H
⊢ (imageIsoRange f).hom ≫ ofHom (Submodule.subtype (LinearMap.range f)) = Limits.image.ι f

Next tactic:
erw [← imageIsoRange_inv_image_ι f, Iso.hom_inv_id_assoc]
theorem cast_descFactorial {n p : ℕ} (h : n ≤ p) :
    (descFactorial (p - 1) n : ZMod p) = (-1) ^ n * n ! := by
  

Proof state:
n p : ℕ
h : n ≤ p
⊢ ↑(descFactorial (p - 1) n) = (-1) ^ n * ↑n !

Next tactic:
rw [descFactorial_eq_prod_range, ← prod_range_add_one_eq_factorial]