l3lab/ntp-mathlib huggingface dataset:
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]
  have hy : y ∈ Algebra.adjoin R (T : Set S) := 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'✝
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
⊢ y ∈ Algebra.adjoin R ↑T

Next tactic:
rw [hT]
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]
  have hy : y ∈ Algebra.adjoin R (T : Set S) := by rw [hT]; 

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)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
⊢ y ∈ ⊤

Next tactic:
trivial
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]
  have hy : y ∈ Algebra.adjoin R (T : Set S) := by rw [hT]; trivial
  

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
hy : y ∈ Algebra.adjoin R ↑T
⊢ 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:
replace hy : algebraMap S S' y ∈ (Algebra.adjoin R (T : Set S)).map fₐ :=
    Subalgebra.mem_map.mpr ⟨_, hy, rfl⟩
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]
  have hy : y ∈ Algebra.adjoin R (T : Set S) := by rw [hT]; trivial
  replace hy : algebraMap S S' y ∈ (Algebra.adjoin R (T : Set S)).map fₐ :=
    Subalgebra.mem_map.mpr ⟨_, hy, rfl⟩
  

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
hy : (algebraMap S S') y ∈ Subalgebra.map fₐ (Algebra.adjoin R ↑T)
⊢ 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:
rw [fₐ.map_adjoin T] at hy
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]
  have hy : y ∈ Algebra.adjoin R (T : Set S) := by rw [hT]; trivial
  replace hy : algebraMap S S' y ∈ (Algebra.adjoin R (T : Set S)).map fₐ :=
    Subalgebra.mem_map.mpr ⟨_, hy, rfl⟩
  rw [fₐ.map_adjoin T] at hy
  

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
hy : (algebraMap S S') y ∈ Algebra.adjoin R (⇑fₐ '' ↑T)
⊢ 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 H : Algebra.adjoin R (algebraMap S S' '' T) ≤
      (Algebra.adjoin R' (algebraMap S S' '' T)).restrictScalars R := by
    rw [Algebra.adjoin_le_iff]; exact Algebra.subset_adjoin
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]
  have hy : y ∈ Algebra.adjoin R (T : Set S) := by rw [hT]; trivial
  replace hy : algebraMap S S' y ∈ (Algebra.adjoin R (T : Set S)).map fₐ :=
    Subalgebra.mem_map.mpr ⟨_, hy, rfl⟩
  rw [fₐ.map_adjoin T] at hy
  have H : Algebra.adjoin R (algebraMap S S' '' T) ≤
      (Algebra.adjoin R' (algebraMap S S' '' T)).restrictScalars R := 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'✝
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
hy : (algebraMap S S') y ∈ Algebra.adjoin R (⇑fₐ '' ↑T)
⊢ Algebra.adjoin R (⇑(algebraMap S S') '' ↑T) ≤
    Subalgebra.restrictScalars R (Algebra.adjoin R' (⇑(algebraMap S S') '' ↑T))

Next tactic:
rw [Algebra.adjoin_le_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]
  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]
  have hy : y ∈ Algebra.adjoin R (T : Set S) := by rw [hT]; trivial
  replace hy : algebraMap S S' y ∈ (Algebra.adjoin R (T : Set S)).map fₐ :=
    Subalgebra.mem_map.mpr ⟨_, hy, rfl⟩
  rw [fₐ.map_adjoin T] at hy
  have H : Algebra.adjoin R (algebraMap S S' '' T) ≤
      (Algebra.adjoin R' (algebraMap S S' '' T)).restrictScalars R := by
    rw [Algebra.adjoin_le_iff]; 

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)
T : Finset S
hT : Algebra.adjoin R ↑T = ⊤
y : S
r : R
hr : r ∈ ↑M
hy : (algebraMap S S') y ∈ Algebra.adjoin R (⇑fₐ '' ↑T)
⊢ ⇑(algebraMap S S') '' ↑T ⊆ ↑(Subalgebra.restrictScalars R (Algebra.adjoin R' (⇑(algebraMap S S') '' ↑T)))

Next tactic:
exact Algebra.subset_adjoin
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]
  have hy : y ∈ Algebra.adjoin R (T : Set S) := by rw [hT]; trivial
  replace hy : algebraMap S S' y ∈ (Algebra.adjoin R (T : Set S)).map fₐ :=
    Subalgebra.mem_map.mpr ⟨_, hy, rfl⟩
  rw [fₐ.map_adjoin T] at hy
  have H : Algebra.adjoin R (algebraMap S S' '' T) ≤
      (Algebra.adjoin R' (algebraMap S S' '' T)).restrictScalars R := by
    rw [Algebra.adjoin_le_iff]; exact Algebra.subset_adjoin
  

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
hy : (algebraMap S S') y ∈ Algebra.adjoin R (⇑fₐ '' ↑T)
H :
  Algebra.adjoin R (⇑(algebraMap S S') '' ↑T) ≤
    Subalgebra.restrictScalars R (Algebra.adjoin R' (⇑(algebraMap S S') '' ↑T))
⊢ 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:
convert (Algebra.adjoin R' (algebraMap S S' '' T)).smul_mem (H hy)
    (IsLocalization.mk' R' (1 : R) ⟨r, hr⟩) using 1
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]
  have hy : y ∈ Algebra.adjoin R (T : Set S) := by rw [hT]; trivial
  replace hy : algebraMap S S' y ∈ (Algebra.adjoin R (T : Set S)).map fₐ :=
    Subalgebra.mem_map.mpr ⟨_, hy, rfl⟩
  rw [fₐ.map_adjoin T] at hy
  have H : Algebra.adjoin R (algebraMap S S' '' T) ≤
      (Algebra.adjoin R' (algebraMap S S' '' T)).restrictScalars R := by
    rw [Algebra.adjoin_le_iff]; exact Algebra.subset_adjoin
  convert (Algebra.adjoin R' (algebraMap S S' '' T)).smul_mem (H hy)
    (IsLocalization.mk' R' (1 : R) ⟨r, hr⟩) using 1
  

Proof state:
case h.e'_4
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
hy : (algebraMap S S') y ∈ Algebra.adjoin R (⇑fₐ '' ↑T)
H :
  Algebra.adjoin R (⇑(algebraMap S S') '' ↑T) ≤
    Subalgebra.restrictScalars R (Algebra.adjoin R' (⇑(algebraMap S S') '' ↑T))
⊢ IsLocalization.mk' S' 1 { val := f r, property := (_ : ∃ a ∈ ↑M, f a = f r) } * (algebraMap S S') y =
    IsLocalization.mk' R' 1 { val := r, property := hr } • (algebraMap S S') y

Next tactic:
rw [Algebra.smul_def]
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]
  have hy : y ∈ Algebra.adjoin R (T : Set S) := by rw [hT]; trivial
  replace hy : algebraMap S S' y ∈ (Algebra.adjoin R (T : Set S)).map fₐ :=
    Subalgebra.mem_map.mpr ⟨_, hy, rfl⟩
  rw [fₐ.map_adjoin T] at hy
  have H : Algebra.adjoin R (algebraMap S S' '' T) ≤
      (Algebra.adjoin R' (algebraMap S S' '' T)).restrictScalars R := by
    rw [Algebra.adjoin_le_iff]; exact Algebra.subset_adjoin
  convert (Algebra.adjoin R' (algebraMap S S' '' T)).smul_mem (H hy)
    (IsLocalization.mk' R' (1 : R) ⟨r, hr⟩) using 1
  rw [Algebra.smul_def]
  

Proof state:
case h.e'_4
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
hy : (algebraMap S S') y ∈ Algebra.adjoin R (⇑fₐ '' ↑T)
H :
  Algebra.adjoin R (⇑(algebraMap S S') '' ↑T) ≤
    Subalgebra.restrictScalars R (Algebra.adjoin R' (⇑(algebraMap S S') '' ↑T))
⊢ IsLocalization.mk' S' 1 { val := f r, property := (_ : ∃ a ∈ ↑M, f a = f r) } * (algebraMap S S') y =
    (algebraMap R' S') (IsLocalization.mk' R' 1 { val := r, property := hr }) * (algebraMap S S') y

Next tactic:
erw [IsLocalization.map_mk' M.le_comap_map]