-- Mathlib/LinearAlgebra/TensorProduct/RightExactness.lean
theorem Algebra.TensorProduct.map_ker (hf : Function.Surjective f) (hg : Function.Surjective g) :
    RingHom.ker (map f g) =
      (RingHom.ker f).map (Algebra.TensorProduct.includeLeft : A →ₐ[R] A ⊗[R] C) ⊔
        (RingHom.ker g).map (Algebra.TensorProduct.includeRight : C →ₐ[R] A ⊗[R] C)

Proof state:
R : Type u_4
inst✝⁸ : CommRing R
A : Type u_5
B : Type u_6
C : Type u_7
D : Type u_8
inst✝⁷ : Ring A
inst✝⁶ : Ring B
inst✝⁵ : Ring C
inst✝⁴ : Ring D
inst✝³ : Algebra R A
inst✝² : Algebra R B
inst✝¹ : Algebra R C
inst✝ : Algebra R D
f : A →ₐ[R] B
g : C →ₐ[R] D
hf : Function.Surjective ⇑f
hg : Function.Surjective ⇑g
this : map f g = (map f (AlgHom.id R D)).comp (map (AlgHom.id R A) g)
⊢ Ideal.comap (↑(map (AlgHom.id R A) g)) (RingHom.ker (map f (AlgHom.id R D))) =
    Ideal.map includeLeft (RingHom.ker f) ⊔ Ideal.comap (map (AlgHom.id R A) g) ⊥

Tactic:
rw [← Ideal.comap_map_of_surjective (map (AlgHom.id R A) g) (LinearMap.lTensor_surjective A hg)]

Result:
R : Type u_4
inst✝⁸ : CommRing R
A : Type u_5
B : Type u_6
C : Type u_7
D : Type u_8
inst✝⁷ : Ring A
inst✝⁶ : Ring B
inst✝⁵ : Ring C
inst✝⁴ : Ring D
inst✝³ : Algebra R A
inst✝² : Algebra R B
inst✝¹ : Algebra R C
inst✝ : Algebra R D
f : A →ₐ[R] B
g : C →ₐ[R] D
hf : Function.Surjective ⇑f
hg : Function.Surjective ⇑g
this : map f g = (map f (AlgHom.id R D)).comp (map (AlgHom.id R A) g)
⊢ Ideal.comap (↑(map (AlgHom.id R A) g)) (RingHom.ker (map f (AlgHom.id R D))) =
    Ideal.comap (map (AlgHom.id R A) g) (Ideal.map (map (AlgHom.id R A) g) (Ideal.map includeLeft (RingHom.ker f)))

Proof state:
R : Type u_4
inst✝⁸ : CommRing R
A : Type u_5
B : Type u_6
C : Type u_7
D : Type u_8
inst✝⁷ : Ring A
inst✝⁶ : Ring B
inst✝⁵ : Ring C
inst✝⁴ : Ring D
inst✝³ : Algebra R A
inst✝² : Algebra R B
inst✝¹ : Algebra R C
inst✝ : Algebra R D
f : A →ₐ[R] B
g : C →ₐ[R] D
hf : Function.Surjective ⇑f
hg : Function.Surjective ⇑g
this : map f g = (map f (AlgHom.id R D)).comp (map (AlgHom.id R A) g)
⊢ Ideal.comap (↑(map (AlgHom.id R A) g)) (RingHom.ker (map f (AlgHom.id R D))) =
    Ideal.comap (map (AlgHom.id R A) g) (Ideal.map (map (AlgHom.id R A) g) (Ideal.map includeLeft (RingHom.ker f)))

Tactic:
rw [Algebra.TensorProduct.rTensor_ker _ hf]

Result:
R : Type u_4
inst✝⁸ : CommRing R
A : Type u_5
B : Type u_6
C : Type u_7
D : Type u_8
inst✝⁷ : Ring A
inst✝⁶ : Ring B
inst✝⁵ : Ring C
inst✝⁴ : Ring D
inst✝³ : Algebra R A
inst✝² : Algebra R B
inst✝¹ : Algebra R C
inst✝ : Algebra R D
f : A →ₐ[R] B
g : C →ₐ[R] D
hf : Function.Surjective ⇑f
hg : Function.Surjective ⇑g
this : map f g = (map f (AlgHom.id R D)).comp (map (AlgHom.id R A) g)
⊢ Ideal.comap (↑(map (AlgHom.id R A) g)) (Ideal.map includeLeft (RingHom.ker f)) =
    Ideal.comap (map (AlgHom.id R A) g) (Ideal.map (map (AlgHom.id R A) g) (Ideal.map includeLeft (RingHom.ker f)))

Proof state:
R : Type u_4
inst✝⁸ : CommRing R
A : Type u_5
B : Type u_6
C : Type u_7
D : Type u_8
inst✝⁷ : Ring A
inst✝⁶ : Ring B
inst✝⁵ : Ring C
inst✝⁴ : Ring D
inst✝³ : Algebra R A
inst✝² : Algebra R B
inst✝¹ : Algebra R C
inst✝ : Algebra R D
f : A →ₐ[R] B
g : C →ₐ[R] D
hf : Function.Surjective ⇑f
hg : Function.Surjective ⇑g
this : map f g = (map f (AlgHom.id R D)).comp (map (AlgHom.id R A) g)
⊢ Ideal.comap (↑(map (AlgHom.id R A) g)) (RingHom.ker (map f (AlgHom.id R D))) =
    Ideal.map includeLeft (RingHom.ker f) ⊔ Ideal.map includeRight (RingHom.ker g)

Tactic:
rw [← Algebra.TensorProduct.lTensor_ker _ hg, RingHom.ker_eq_comap_bot (map (AlgHom.id R A) g)]

Result:
R : Type u_4
inst✝⁸ : CommRing R
A : Type u_5
B : Type u_6
C : Type u_7
D : Type u_8
inst✝⁷ : Ring A
inst✝⁶ : Ring B
inst✝⁵ : Ring C
inst✝⁴ : Ring D
inst✝³ : Algebra R A
inst✝² : Algebra R B
inst✝¹ : Algebra R C
inst✝ : Algebra R D
f : A →ₐ[R] B
g : C →ₐ[R] D
hf : Function.Surjective ⇑f
hg : Function.Surjective ⇑g
this : map f g = (map f (AlgHom.id R D)).comp (map (AlgHom.id R A) g)
⊢ Ideal.comap (↑(map (AlgHom.id R A) g)) (RingHom.ker (map f (AlgHom.id R D))) =
    Ideal.map includeLeft (RingHom.ker f) ⊔ Ideal.comap (map (AlgHom.id R A) g) ⊥

Proof state:
R : Type u_4
inst✝⁸ : CommRing R
A : Type u_5
B : Type u_6
C : Type u_7
D : Type u_8
inst✝⁷ : Ring A
inst✝⁶ : Ring B
inst✝⁵ : Ring C
inst✝⁴ : Ring D
inst✝³ : Algebra R A
inst✝² : Algebra R B
inst✝¹ : Algebra R C
inst✝ : Algebra R D
f : A →ₐ[R] B
g : C →ₐ[R] D
hf : Function.Surjective ⇑f
hg : Function.Surjective ⇑g
this : map f g = (map f (AlgHom.id R D)).comp (map (AlgHom.id R A) g)
⊢ RingHom.ker ((map f (AlgHom.id R D)).comp (map (AlgHom.id R A) g)) =
    Ideal.map includeLeft (RingHom.ker f) ⊔ Ideal.map includeRight (RingHom.ker g)

Tactic:
simp only [AlgHom.ker_coe, AlgHom.comp_toRingHom]

Result:
R : Type u_4
inst✝⁸ : CommRing R
A : Type u_5
B : Type u_6
C : Type u_7
D : Type u_8
inst✝⁷ : Ring A
inst✝⁶ : Ring B
inst✝⁵ : Ring C
inst✝⁴ : Ring D
inst✝³ : Algebra R A
inst✝² : Algebra R B
inst✝¹ : Algebra R C
inst✝ : Algebra R D
f : A →ₐ[R] B
g : C →ₐ[R] D
hf : Function.Surjective ⇑f
hg : Function.Surjective ⇑g
this : map f g = (map f (AlgHom.id R D)).comp (map (AlgHom.id R A) g)
⊢ RingHom.ker ((↑(map f (AlgHom.id R D))).comp ↑(map (AlgHom.id R A) g)) =
    Ideal.map includeLeft (RingHom.ker ↑f) ⊔ Ideal.map includeRight (RingHom.ker ↑g)

Proof state:
R : Type u_4
inst✝⁸ : CommRing R
A : Type u_5
B : Type u_6
C : Type u_7
D : Type u_8
inst✝⁷ : Ring A
inst✝⁶ : Ring B
inst✝⁵ : Ring C
inst✝⁴ : Ring D
inst✝³ : Algebra R A
inst✝² : Algebra R B
inst✝¹ : Algebra R C
inst✝ : Algebra R D
f : A →ₐ[R] B
g : C →ₐ[R] D
hf : Function.Surjective ⇑f
hg : Function.Surjective ⇑g
this : map f g = (map f (AlgHom.id R D)).comp (map (AlgHom.id R A) g)
⊢ Ideal.map includeLeft (RingHom.ker f) = Ideal.map (map (AlgHom.id R A) g) (Ideal.map includeLeft (RingHom.ker f))

Tactic:
simp only [AlgHom.coe_ideal_map, Ideal.map_map]

Result:
R : Type u_4
inst✝⁸ : CommRing R
A : Type u_5
B : Type u_6
C : Type u_7
D : Type u_8
inst✝⁷ : Ring A
inst✝⁶ : Ring B
inst✝⁵ : Ring C
inst✝⁴ : Ring D
inst✝³ : Algebra R A
inst✝² : Algebra R B
inst✝¹ : Algebra R C
inst✝ : Algebra R D
f : A →ₐ[R] B
g : C →ₐ[R] D
hf : Function.Surjective ⇑f
hg : Function.Surjective ⇑g
this : map f g = (map f (AlgHom.id R D)).comp (map (AlgHom.id R A) g)
⊢ Ideal.map (↑includeLeft) (RingHom.ker f) = Ideal.map ((↑(map (AlgHom.id R A) g)).comp ↑includeLeft) (RingHom.ker f)