-- Mathlib/RingTheory/RingHom/FinitePresentation.lean
theorem finitePresentation_localizationPreserves : LocalizationPreserves @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
⊢ (IsLocalization.map S' f ⋯).FinitePresentation

Tactic:
let f' : R' →+* S' := IsLocalization.map S' f M.le_comap_map

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 ⋯
⊢ (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
this✝ : IsLocalizedModule MX k
this : Module.Finite (MvPolynomial (Fin n) R) ↥(ker g)
⊢ (IsLocalization.map S' f ⋯).FinitePresentation

Tactic:
exact ⟨n, g', IsLocalization.mapₐ_surjective_of_surjective M R' _ S' g hgsurj,
  Module.Finite.iff_fg.mp (Module.Finite.of_isLocalizedModule MX k)⟩

Result:
no goals

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

Tactic:
haveI : IsScalarTower R R' S' :=
  IsScalarTower.of_algebraMap_eq' (IsLocalization.map_comp M.le_comap_map).symm

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

Tactic:
obtain ⟨n, g, hgsurj, hgker⟩ := hf

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
⊢ (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
this : IsLocalizedModule MX k
⊢ (IsLocalization.map S' f ⋯).FinitePresentation

Tactic:
have : Module.Finite (MvPolynomial (Fin n) R) (ker g) := Module.Finite.iff_fg.mpr hgker

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
this : Module.Finite (MvPolynomial (Fin n) R) ↥(ker g)
⊢ (IsLocalization.map S' f ⋯).FinitePresentation