l3lab/ntp-mathlib huggingface dataset:
theorem finite_ofLocalizationSpan : RingHom.OfLocalizationSpan @RingHom.Finite := by
  rw [RingHom.ofLocalizationSpan_iff_finite]
  introv R hs H
  -- We first setup the instances
  letI := f.toAlgebra
  letI := fun r : s => (Localization.awayMap f r).toAlgebra
  have : ∀ r : s,
      IsLocalization ((Submonoid.powers (r : R)).map (algebraMap R S)) (Localization.Away (f r)) :=
    by intro r; rw [Submonoid.map_powers]; exact Localization.isLocalization
  haveI : ∀ r : s, IsScalarTower R (Localization.Away (r : R)) (Localization.Away (f r)) :=
    fun r => IsScalarTower.of_algebraMap_eq'
      (IsLocalization.map_comp (Submonoid.powers (r : R)).le_comap_map).symm
  -- By the hypothesis, we may find a finite generating set for each `Sᵣ`. This set can then be
  -- lifted into `R` by multiplying a sufficiently large power of `r`. I claim that the union of
  -- these generates `S`.
  constructor
  replace H := fun r => (H r).1
  choose s₁ s₂ using H
  let sf := fun x : s => IsLocalization.finsetIntegerMultiple (Submonoid.powers (f x)) (s₁ x)
  use s.attach.biUnion sf
  rw [Submodule.span_attach_biUnion, eq_top_iff]
  -- It suffices to show that `r ^ n • x ∈ span T` for each `r : s`, since `{ r ^ n }` spans `R`.
  -- This then follows from the fact that each `x : R` is a linear combination of the generating set
  -- of `Sᵣ`. By multiplying a sufficiently large power of `r`, we can cancel out the `r`s in the
  -- denominators of both the generating set and the coefficients.
  rintro x -
  apply Submodule.mem_of_span_eq_top_of_smul_pow_mem _ (s : Set R) hs _ _
  intro r
  obtain ⟨⟨_, n₁, rfl⟩, hn₁⟩ :=
    multiple_mem_span_of_mem_localization_span (Submonoid.powers (r : R))
      (Localization.Away (r : R)) (s₁ r : Set (Localization.Away (f r))) (algebraMap S _ x)
      (by rw [s₂ r]; trivial)
  dsimp only at hn₁
  

Proof state:
case intro.mk.intro
R✝ S✝ : Type u
inst✝⁷ : CommRing R✝
inst✝⁶ : CommRing S✝
M : Submonoid R✝
N : Submonoid S✝
R' S' : Type u
inst✝⁵ : CommRing R'
inst✝⁴ : CommRing S'
f✝ : R✝ →+* S✝
inst✝³ : Algebra R✝ R'
inst✝² : Algebra S✝ S'
R S : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
s : Finset R
hs : Ideal.span ↑s = ⊤
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : (r : { x // x ∈ s }) → Algebra (Localization.Away ↑r) (Localization.Away (f ↑r)) :=
  fun r => RingHom.toAlgebra (Localization.awayMap f ↑r)
this✝ :
  ∀ (r : { x // x ∈ s }),
    IsLocalization (Submonoid.map (algebraMap R S) (Submonoid.powers ↑r)) (Localization.Away (f ↑r))
this : ∀ (r : { x // x ∈ s }), IsScalarTower R (Localization.Away ↑r) (Localization.Away (f ↑r))
s₁ : (r : { x // x ∈ s }) → Finset (Localization.Away (f ↑r))
s₂ : ∀ (r : { x // x ∈ s }), Submodule.span (Localization.Away ↑r) ↑(s₁ r) = ⊤
sf : { x // x ∈ s } → Finset S := fun x => IsLocalization.finsetIntegerMultiple (Submonoid.powers (f ↑x)) (s₁ x)
x : S
r : ↑↑s
n₁ : ℕ
hn₁ :
  { val := ↑r ^ n₁, property := (_ : ∃ y, ↑r ^ y = ↑r ^ n₁) } • (algebraMap S (Localization.Away (f ↑r))) x ∈
    Submodule.span R ↑(s₁ r)
⊢ ∃ n, ↑r ^ n • x ∈ ⨆ x, Submodule.span R ↑(sf x)

Next tactic:
rw [Submonoid.smul_def, Algebra.smul_def, IsScalarTower.algebraMap_apply R S, ← map_mul] at hn₁
theorem localization_finiteType : RingHom.LocalizationPreserves @RingHom.FiniteType := by
  

Proof state:
R S : Type u
inst✝⁵ : CommRing R
inst✝⁴ : CommRing S
M : Submonoid R
N : Submonoid S
R' S' : Type u
inst✝³ : CommRing R'
inst✝² : CommRing S'
f : R →+* S
inst✝¹ : Algebra R R'
inst✝ : Algebra S S'
⊢ RingHom.LocalizationPreserves @RingHom.FiniteType

Next tactic:
introv R hf
theorem localization_finiteType : RingHom.LocalizationPreserves @RingHom.FiniteType := by
  introv R hf
  -- mirrors the proof of `localization_map_finite`
  

Proof state:
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
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 : RingHom.FiniteType f
⊢ RingHom.FiniteType (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))

Next tactic:
letI := f.toAlgebra
theorem localization_finiteType : RingHom.LocalizationPreserves @RingHom.FiniteType := by
  introv R hf
  -- mirrors the proof of `localization_map_finite`
  letI := f.toAlgebra
  

Proof state:
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
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 : RingHom.FiniteType f
this : Algebra R S := RingHom.toAlgebra f
⊢ RingHom.FiniteType (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))

Next tactic:
letI := ((algebraMap S S').comp f).toAlgebra
theorem localization_finiteType : RingHom.LocalizationPreserves @RingHom.FiniteType := by
  introv R hf
  -- mirrors the proof of `localization_map_finite`
  letI := f.toAlgebra
  letI := ((algebraMap S S').comp f).toAlgebra
  

Proof state:
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
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 : RingHom.FiniteType f
this✝ : Algebra R S := RingHom.toAlgebra f
this : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
⊢ RingHom.FiniteType (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))

Next tactic:
let f' : R' →+* S' := IsLocalization.map S' f (Submonoid.le_comap_map M)
theorem localization_finiteType : RingHom.LocalizationPreserves @RingHom.FiniteType := by
  introv R hf
  -- mirrors the proof of `localization_map_finite`
  letI := f.toAlgebra
  letI := ((algebraMap S S').comp f).toAlgebra
  let f' : R' →+* S' := IsLocalization.map S' f (Submonoid.le_comap_map M)
  

Proof state:
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
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 : RingHom.FiniteType f
this✝ : Algebra R S := RingHom.toAlgebra f
this : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
⊢ RingHom.FiniteType (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))

Next tactic:
letI := f'.toAlgebra
theorem localization_finiteType : RingHom.LocalizationPreserves @RingHom.FiniteType := by
  introv R hf
  -- mirrors the proof of `localization_map_finite`
  letI := f.toAlgebra
  letI := ((algebraMap S S').comp f).toAlgebra
  let f' : R' →+* S' := IsLocalization.map S' f (Submonoid.le_comap_map M)
  letI := f'.toAlgebra
  

Proof state:
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
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 : RingHom.FiniteType f
this✝¹ : Algebra R S := RingHom.toAlgebra f
this✝ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this : Algebra R' S' := RingHom.toAlgebra f'
⊢ RingHom.FiniteType (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))

Next tactic:
haveI : IsScalarTower R R' S' :=
    IsScalarTower.of_algebraMap_eq' (IsLocalization.map_comp M.le_comap_map).symm
theorem localization_finiteType : RingHom.LocalizationPreserves @RingHom.FiniteType := by
  introv R hf
  -- mirrors the proof of `localization_map_finite`
  letI := f.toAlgebra
  letI := ((algebraMap S S').comp f).toAlgebra
  let f' : R' →+* S' := IsLocalization.map S' f (Submonoid.le_comap_map M)
  letI := f'.toAlgebra
  haveI : IsScalarTower R R' S' :=
    IsScalarTower.of_algebraMap_eq' (IsLocalization.map_comp M.le_comap_map).symm
  

Proof state:
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
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 : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
⊢ RingHom.FiniteType (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))

Next tactic:
let fₐ : S →ₐ[R] S' := AlgHom.mk' (algebraMap S S') fun c x => RingHom.map_mul _ _ _
theorem localization_finiteType : RingHom.LocalizationPreserves @RingHom.FiniteType := by
  introv R hf
  -- mirrors the proof of `localization_map_finite`
  letI := f.toAlgebra
  letI := ((algebraMap S S').comp f).toAlgebra
  let f' : R' →+* S' := IsLocalization.map S' f (Submonoid.le_comap_map M)
  letI := f'.toAlgebra
  haveI : IsScalarTower R R' S' :=
    IsScalarTower.of_algebraMap_eq' (IsLocalization.map_comp M.le_comap_map).symm
  let fₐ : S →ₐ[R] S' := AlgHom.mk' (algebraMap S S') fun c x => RingHom.map_mul _ _ _
  

Proof state:
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
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 : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
  AlgHom.mk' (algebraMap S S')
    (_ : ∀ (c : R) (x : S), (algebraMap S S') (f c * x) = (algebraMap S S') (f c) * (algebraMap S S') x)
⊢ RingHom.FiniteType (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))

Next tactic:
obtain ⟨T, hT⟩ := id hf
theorem localization_finiteType : RingHom.LocalizationPreserves @RingHom.FiniteType := by
  introv R hf
  -- mirrors the proof of `localization_map_finite`
  letI := f.toAlgebra
  letI := ((algebraMap S S').comp f).toAlgebra
  let f' : R' →+* S' := IsLocalization.map S' f (Submonoid.le_comap_map M)
  letI := f'.toAlgebra
  haveI : IsScalarTower R R' S' :=
    IsScalarTower.of_algebraMap_eq' (IsLocalization.map_comp M.le_comap_map).symm
  let fₐ : S →ₐ[R] S' := AlgHom.mk' (algebraMap S S') fun c x => RingHom.map_mul _ _ _
  obtain ⟨T, hT⟩ := id hf
  

Proof state:
case mk.intro
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
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 : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
  AlgHom.mk' (algebraMap S S')
    (_ : ∀ (c : R) (x : S), (algebraMap S S') (f c * x) = (algebraMap S S') (f c) * (algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
⊢ RingHom.FiniteType (IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M)))

Next tactic:
use T.image (algebraMap S S')
theorem localization_finiteType : RingHom.LocalizationPreserves @RingHom.FiniteType := by
  introv R hf
  -- mirrors the proof of `localization_map_finite`
  letI := f.toAlgebra
  letI := ((algebraMap S S').comp f).toAlgebra
  let f' : R' →+* S' := IsLocalization.map S' f (Submonoid.le_comap_map M)
  letI := f'.toAlgebra
  haveI : IsScalarTower R R' S' :=
    IsScalarTower.of_algebraMap_eq' (IsLocalization.map_comp M.le_comap_map).symm
  let fₐ : S →ₐ[R] S' := AlgHom.mk' (algebraMap S S') fun c x => RingHom.map_mul _ _ _
  obtain ⟨T, hT⟩ := id hf
  use T.image (algebraMap S S')
  

Proof state:
case h
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
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 : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
  AlgHom.mk' (algebraMap S S')
    (_ : ∀ (c : R) (x : S), (algebraMap S S') (f c * x) = (algebraMap S S') (f c) * (algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
⊢ Algebra.adjoin R' ↑(Finset.image (⇑(algebraMap S S')) T) = ⊤

Next tactic:
rw [eq_top_iff]
theorem localization_finiteType : RingHom.LocalizationPreserves @RingHom.FiniteType := by
  introv R hf
  -- mirrors the proof of `localization_map_finite`
  letI := f.toAlgebra
  letI := ((algebraMap S S').comp f).toAlgebra
  let f' : R' →+* S' := IsLocalization.map S' f (Submonoid.le_comap_map M)
  letI := f'.toAlgebra
  haveI : IsScalarTower R R' S' :=
    IsScalarTower.of_algebraMap_eq' (IsLocalization.map_comp M.le_comap_map).symm
  let fₐ : S →ₐ[R] S' := AlgHom.mk' (algebraMap S S') fun c x => RingHom.map_mul _ _ _
  obtain ⟨T, hT⟩ := id hf
  use T.image (algebraMap S S')
  rw [eq_top_iff]
  

Proof state:
case h
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
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 : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
  AlgHom.mk' (algebraMap S S')
    (_ : ∀ (c : R) (x : S), (algebraMap S S') (f c * x) = (algebraMap S S') (f c) * (algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
⊢ ⊤ ≤ Algebra.adjoin R' ↑(Finset.image (⇑(algebraMap S S')) T)

Next tactic:
rintro x -
theorem localization_finiteType : RingHom.LocalizationPreserves @RingHom.FiniteType := by
  introv R hf
  -- mirrors the proof of `localization_map_finite`
  letI := f.toAlgebra
  letI := ((algebraMap S S').comp f).toAlgebra
  let f' : R' →+* S' := IsLocalization.map S' f (Submonoid.le_comap_map M)
  letI := f'.toAlgebra
  haveI : IsScalarTower R R' S' :=
    IsScalarTower.of_algebraMap_eq' (IsLocalization.map_comp M.le_comap_map).symm
  let fₐ : S →ₐ[R] S' := AlgHom.mk' (algebraMap S S') fun c x => RingHom.map_mul _ _ _
  obtain ⟨T, hT⟩ := id hf
  use T.image (algebraMap S S')
  rw [eq_top_iff]
  rintro x -
  

Proof state:
case h
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
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 : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
  AlgHom.mk' (algebraMap S S')
    (_ : ∀ (c : R) (x : S), (algebraMap S S') (f c * x) = (algebraMap S S') (f c) * (algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
x : S'
⊢ x ∈ Algebra.adjoin R' ↑(Finset.image (⇑(algebraMap S S')) T)

Next tactic:
obtain ⟨y, ⟨_, ⟨r, hr, rfl⟩⟩, rfl⟩ := IsLocalization.mk'_surjective (M.map f) x
theorem localization_finiteType : RingHom.LocalizationPreserves @RingHom.FiniteType := by
  introv R hf
  -- mirrors the proof of `localization_map_finite`
  letI := f.toAlgebra
  letI := ((algebraMap S S').comp f).toAlgebra
  let f' : R' →+* S' := IsLocalization.map S' f (Submonoid.le_comap_map M)
  letI := f'.toAlgebra
  haveI : IsScalarTower R R' S' :=
    IsScalarTower.of_algebraMap_eq' (IsLocalization.map_comp M.le_comap_map).symm
  let fₐ : S →ₐ[R] S' := AlgHom.mk' (algebraMap S S') fun c x => RingHom.map_mul _ _ _
  obtain ⟨T, hT⟩ := id hf
  use T.image (algebraMap S S')
  rw [eq_top_iff]
  rintro x -
  obtain ⟨y, ⟨_, ⟨r, hr, rfl⟩⟩, rfl⟩ := IsLocalization.mk'_surjective (M.map f) x
  

Proof state:
case h.intro.intro.mk.intro.intro
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
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 : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
  AlgHom.mk' (algebraMap S S')
    (_ : ∀ (c : R) (x : S), (algebraMap S S') (f c * x) = (algebraMap S S') (f c) * (algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
⊢ IsLocalization.mk' S' y { val := f r, property := (_ : ∃ a ∈ ↑M, f a = f r) } ∈
    Algebra.adjoin R' ↑(Finset.image (⇑(algebraMap S S')) T)

Next tactic:
rw [IsLocalization.mk'_eq_mul_mk'_one, mul_comm, Finset.coe_image]
theorem localization_finiteType : RingHom.LocalizationPreserves @RingHom.FiniteType := by
  introv R hf
  -- mirrors the proof of `localization_map_finite`
  letI := f.toAlgebra
  letI := ((algebraMap S S').comp f).toAlgebra
  let f' : R' →+* S' := IsLocalization.map S' f (Submonoid.le_comap_map M)
  letI := f'.toAlgebra
  haveI : IsScalarTower R R' S' :=
    IsScalarTower.of_algebraMap_eq' (IsLocalization.map_comp M.le_comap_map).symm
  let fₐ : S →ₐ[R] S' := AlgHom.mk' (algebraMap S S') fun c x => RingHom.map_mul _ _ _
  obtain ⟨T, hT⟩ := id hf
  use T.image (algebraMap S S')
  rw [eq_top_iff]
  rintro x -
  obtain ⟨y, ⟨_, ⟨r, hr, rfl⟩⟩, rfl⟩ := IsLocalization.mk'_surjective (M.map f) x
  rw [IsLocalization.mk'_eq_mul_mk'_one, mul_comm, Finset.coe_image]
  

Proof state:
case h.intro.intro.mk.intro.intro
R✝ S✝ : Type u
inst✝¹³ : CommRing R✝
inst✝¹² : CommRing S✝
M✝ : Submonoid R✝
N : Submonoid S✝
R'✝ S'✝ : Type u
inst✝¹¹ : CommRing R'✝
inst✝¹⁰ : CommRing S'✝
f✝ : R✝ →+* S✝
inst✝⁹ : Algebra R✝ R'✝
inst✝⁸ : Algebra S✝ S'✝
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 : RingHom.FiniteType f
this✝² : Algebra R S := RingHom.toAlgebra f
this✝¹ : Algebra R S' := RingHom.toAlgebra (RingHom.comp (algebraMap S S') f)
f' : R' →+* S' := IsLocalization.map S' f (_ : M ≤ Submonoid.comap f (Submonoid.map f M))
this✝ : Algebra R' S' := RingHom.toAlgebra f'
this : IsScalarTower R R' S'
fₐ : S →ₐ[R] S' :=
  AlgHom.mk' (algebraMap S S')
    (_ : ∀ (c : R) (x : S), (algebraMap S S') (f c * x) = (algebraMap S S') (f c) * (algebraMap S S') x)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
⊢ IsLocalization.mk' S' 1 { val := f r, property := (_ : ∃ a ∈ ↑M, f a = f r) } * (algebraMap S S') y ∈
    Algebra.adjoin R' (⇑(algebraMap S S') '' ↑T)

Next tactic:
have hy : y ∈ Algebra.adjoin R (T : Set S) := by rw [hT]; trivial