-- 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)
⊢ 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:
rw [← RingHom.comap_ker]

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.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
⊢ RingHom.ker (map f g) = Ideal.map includeLeft (RingHom.ker f) ⊔ Ideal.map includeRight (RingHom.ker g)

Tactic:
have : map f g = (map f (AlgHom.id R D)).comp (map (AlgHom.id R A) g) := ext rfl rfl

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 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)).comp ↑includeLeft) (RingHom.ker f)

Tactic:
rw [← AlgHom.comp_toRingHom, Algebra.TensorProduct.map_comp_includeLeft]

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 (↑(includeLeft.comp (AlgHom.id R A))) (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.map (↑includeLeft) (RingHom.ker f) = Ideal.map (↑(includeLeft.comp (AlgHom.id R A))) (RingHom.ker f)

Tactic:
rfl

Result:
no goals

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)) (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)))

Tactic:
apply congr_arg₂ _ rfl

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) (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)
⊢ RingHom.ker (map f g) = Ideal.map includeLeft (RingHom.ker f) ⊔ Ideal.map includeRight (RingHom.ker g)

Tactic:
rw [this]

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.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:
simp only [← AlgHom.ker_coe]

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.map includeRight (RingHom.ker g)