-- Mathlib/RingTheory/RingHom/FinitePresentation.lean
theorem finitePresentation_localizationPreserves : LocalizationPreserves @FinitePresentation

Proof state:
case mk.intro.intro.intro
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝⁴ : Algebra R S := f.toAlgebra
this✝³ : Algebra R S' := ((algebraMap S S').comp f).toAlgebra
f' : R' →+* S' := IsLocalization.map S' f ⋯
this✝² : Algebra R' S' := f'.toAlgebra
this✝¹ : IsScalarTower R R' S'
n : ℕ
g : MvPolynomial (Fin n) R →ₐ[R] S
hgsurj : Function.Surjective ⇑g
hgker : (ker g.toRingHom).FG
MX : Submonoid (MvPolynomial (Fin n) R) := Algebra.algebraMapSubmonoid (MvPolynomial (Fin n) R) M
this✝ : IsLocalization MX (MvPolynomial (Fin n) R')
this : IsScalarTower R S S'
⊢ (IsLocalization.map S' f ⋯).FinitePresentation

Tactic:
haveI : IsLocalization (Algebra.algebraMapSubmonoid S M) S' :=
  inferInstanceAs <| IsLocalization (M.map f) S'

Result:
case mk.intro.intro.intro
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝⁵ : Algebra R S := f.toAlgebra
this✝⁴ : Algebra R S' := ((algebraMap S S').comp f).toAlgebra
f' : R' →+* S' := IsLocalization.map S' f ⋯
this✝³ : Algebra R' S' := f'.toAlgebra
this✝² : IsScalarTower R R' S'
n : ℕ
g : MvPolynomial (Fin n) R →ₐ[R] S
hgsurj : Function.Surjective ⇑g
hgker : (ker g.toRingHom).FG
MX : Submonoid (MvPolynomial (Fin n) R) := Algebra.algebraMapSubmonoid (MvPolynomial (Fin n) R) M
this✝¹ : IsLocalization MX (MvPolynomial (Fin n) R')
this✝ : IsScalarTower R S S'
this : IsLocalization (Algebra.algebraMapSubmonoid S M) S'
⊢ (IsLocalization.map S' f ⋯).FinitePresentation

Proof state:
case mk.intro.intro.intro
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝⁵ : Algebra R S := f.toAlgebra
this✝⁴ : Algebra R S' := ((algebraMap S S').comp f).toAlgebra
f' : R' →+* S' := IsLocalization.map S' f ⋯
this✝³ : Algebra R' S' := f'.toAlgebra
this✝² : IsScalarTower R R' S'
n : ℕ
g : MvPolynomial (Fin n) R →ₐ[R] S
hgsurj : Function.Surjective ⇑g
hgker : (ker g.toRingHom).FG
MX : Submonoid (MvPolynomial (Fin n) R) := Algebra.algebraMapSubmonoid (MvPolynomial (Fin n) R) M
this✝¹ : IsLocalization MX (MvPolynomial (Fin n) R')
this✝ : IsScalarTower R S S'
this : IsLocalization (Algebra.algebraMapSubmonoid S M) S'
g' : MvPolynomial (Fin n) R' →ₐ[R'] S' := IsLocalization.mapₐ M R' (MvPolynomial (Fin n) R') S' g
⊢ (IsLocalization.map S' f ⋯).FinitePresentation

Tactic:
let k : RingHom.ker g →ₗ[MvPolynomial (Fin n) R] RingHom.ker g' :=
  AlgHom.toKerIsLocalization M R' _ S' g

Result:
case mk.intro.intro.intro
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝⁵ : Algebra R S := f.toAlgebra
this✝⁴ : Algebra R S' := ((algebraMap S S').comp f).toAlgebra
f' : R' →+* S' := IsLocalization.map S' f ⋯
this✝³ : Algebra R' S' := f'.toAlgebra
this✝² : IsScalarTower R R' S'
n : ℕ
g : MvPolynomial (Fin n) R →ₐ[R] S
hgsurj : Function.Surjective ⇑g
hgker : (ker g.toRingHom).FG
MX : Submonoid (MvPolynomial (Fin n) R) := Algebra.algebraMapSubmonoid (MvPolynomial (Fin n) R) M
this✝¹ : IsLocalization MX (MvPolynomial (Fin n) R')
this✝ : IsScalarTower R S S'
this : IsLocalization (Algebra.algebraMapSubmonoid S M) S'
g' : MvPolynomial (Fin n) R' →ₐ[R'] S' := IsLocalization.mapₐ M R' (MvPolynomial (Fin n) R') S' g
k : ↥(ker g) →ₛₗ[id (MvPolynomial (Fin n) R)] ↥(ker g') :=
  AlgHom.toKerIsLocalization M R' (MvPolynomial (Fin n) R') S' g
⊢ (IsLocalization.map S' f ⋯).FinitePresentation

Proof state:
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : f.FinitePresentation
this : Algebra R S := f.toAlgebra
⊢ (IsLocalization.map S' f ⋯).FinitePresentation

Tactic:
letI := ((algebraMap S S').comp f).toAlgebra

Result:
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : f.FinitePresentation
this✝ : Algebra R S := f.toAlgebra
this : Algebra R S' := ((algebraMap S S').comp f).toAlgebra
⊢ (IsLocalization.map S' f ⋯).FinitePresentation

Proof state:
case mk.intro.intro.intro
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝³ : Algebra R S := f.toAlgebra
this✝² : Algebra R S' := ((algebraMap S S').comp f).toAlgebra
f' : R' →+* S' := IsLocalization.map S' f ⋯
this✝¹ : Algebra R' S' := f'.toAlgebra
this✝ : IsScalarTower R R' S'
n : ℕ
g : MvPolynomial (Fin n) R →ₐ[R] S
hgsurj : Function.Surjective ⇑g
hgker : (ker g.toRingHom).FG
MX : Submonoid (MvPolynomial (Fin n) R) := Algebra.algebraMapSubmonoid (MvPolynomial (Fin n) R) M
this : IsLocalization MX (MvPolynomial (Fin n) R')
⊢ (IsLocalization.map S' f ⋯).FinitePresentation

Tactic:
haveI : IsScalarTower R S S' := IsScalarTower.of_algebraMap_eq' rfl

Result:
case mk.intro.intro.intro
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
this✝⁴ : Algebra R S := f.toAlgebra
this✝³ : Algebra R S' := ((algebraMap S S').comp f).toAlgebra
f' : R' →+* S' := IsLocalization.map S' f ⋯
this✝² : Algebra R' S' := f'.toAlgebra
this✝¹ : IsScalarTower R R' S'
n : ℕ
g : MvPolynomial (Fin n) R →ₐ[R] S
hgsurj : Function.Surjective ⇑g
hgker : (ker g.toRingHom).FG
MX : Submonoid (MvPolynomial (Fin n) R) := Algebra.algebraMapSubmonoid (MvPolynomial (Fin n) R) M
this✝ : IsLocalization MX (MvPolynomial (Fin n) R')
this : IsScalarTower R S S'
⊢ (IsLocalization.map S' f ⋯).FinitePresentation

Proof state:
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : f.FinitePresentation
⊢ (IsLocalization.map S' f ⋯).FinitePresentation

Tactic:
letI := f.toAlgebra

Result:
R S : Type u_1
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
f : R →+* S
M : Submonoid R
R' S' : Type u_1
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
inst✝³ : Algebra R R'
inst✝² : Algebra S S'
inst✝¹ : IsLocalization M R'
inst✝ : IsLocalization (Submonoid.map f M) S'
hf : f.FinitePresentation
this : Algebra R S := f.toAlgebra
⊢ (IsLocalization.map S' f ⋯).FinitePresentation