-- 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'
this : IsLocalization (Algebra.algebraMapSubmonoid S M) S'
⊢ (IsLocalization.map S' f ⋯).FinitePresentation

Tactic:
let g' : MvPolynomial (Fin n) R' →ₐ[R'] S' := IsLocalization.mapₐ 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
⊢ (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
this : Algebra R S' := ((algebraMap S S').comp f).toAlgebra
f' : R' →+* S' := IsLocalization.map S' f ⋯
⊢ (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
this✝ : Algebra R S' := ((algebraMap S S').comp f).toAlgebra
f' : R' →+* S' := IsLocalization.map S' f ⋯
this : Algebra R' S' := 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
⊢ (IsLocalization.map S' f ⋯).FinitePresentation

Tactic:
haveI : IsLocalization MX (MvPolynomial (Fin n) R') :=
  inferInstanceAs <| IsLocalization (M.map MvPolynomial.C) (MvPolynomial (Fin n) R')

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

Tactic:
have : IsLocalizedModule MX k := AlgHom.toKerIsLocalization_isLocalizedModule M _ _ _ 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
this : IsLocalizedModule MX k
⊢ (IsLocalization.map S' f ⋯).FinitePresentation

Proof state:
⊢ LocalizationPreserves @FinitePresentation

Tactic:
introv R hf

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
⊢ (IsLocalization.map S' f ⋯).FinitePresentation